activesupport 3.0.pre → 3.0.0.rc
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activesupport might be problematic. Click here for more details.
- data/CHANGELOG +121 -1
- data/README.rdoc +33 -0
- data/lib/active_support.rb +42 -4
- data/lib/active_support/backtrace_cleaner.rb +31 -9
- data/lib/active_support/benchmarkable.rb +1 -0
- data/lib/active_support/buffered_logger.rb +5 -2
- data/lib/active_support/builder.rb +6 -0
- data/lib/active_support/cache.rb +454 -84
- data/lib/active_support/cache/compressed_mem_cache_store.rb +6 -13
- data/lib/active_support/cache/file_store.rb +140 -41
- data/lib/active_support/cache/mem_cache_store.rb +121 -76
- data/lib/active_support/cache/memory_store.rb +127 -27
- data/lib/active_support/cache/strategy/local_cache.rb +111 -58
- data/lib/active_support/cache/synchronized_memory_store.rb +2 -38
- data/lib/active_support/callbacks.rb +105 -76
- data/lib/active_support/configurable.rb +19 -18
- data/lib/active_support/core_ext/array.rb +1 -0
- data/lib/active_support/core_ext/array/access.rb +1 -1
- data/lib/active_support/core_ext/array/conversions.rb +29 -54
- data/lib/active_support/core_ext/array/extract_options.rb +16 -1
- data/lib/active_support/core_ext/array/grouping.rb +1 -1
- data/lib/active_support/core_ext/array/random_access.rb +26 -5
- data/lib/active_support/core_ext/array/uniq_by.rb +17 -0
- data/lib/active_support/core_ext/array/wrap.rb +13 -9
- data/lib/active_support/core_ext/benchmark.rb +0 -12
- data/lib/active_support/core_ext/cgi/escape_skipping_slashes.rb +2 -0
- data/lib/active_support/core_ext/class.rb +2 -1
- data/lib/active_support/core_ext/class/attribute.rb +67 -0
- data/lib/active_support/core_ext/class/attribute_accessors.rb +33 -27
- data/lib/active_support/core_ext/class/delegating_attributes.rb +35 -41
- data/lib/active_support/core_ext/class/inheritable_attributes.rb +23 -14
- data/lib/active_support/core_ext/class/subclasses.rb +50 -0
- data/lib/active_support/core_ext/date/calculations.rb +35 -12
- data/lib/active_support/core_ext/date/conversions.rb +5 -5
- data/lib/active_support/core_ext/date/zones.rb +14 -0
- data/lib/active_support/core_ext/date_time/calculations.rb +3 -1
- data/lib/active_support/core_ext/date_time/conversions.rb +24 -5
- data/lib/active_support/core_ext/date_time/zones.rb +4 -0
- data/lib/active_support/core_ext/enumerable.rb +5 -9
- data/lib/active_support/core_ext/exception.rb +0 -47
- data/lib/active_support/core_ext/file.rb +1 -0
- data/lib/active_support/core_ext/file/atomic.rb +3 -2
- data/lib/active_support/core_ext/file/path.rb +5 -0
- data/lib/active_support/core_ext/float/rounding.rb +3 -2
- data/lib/active_support/core_ext/hash/conversions.rb +65 -145
- data/lib/active_support/core_ext/hash/deep_merge.rb +6 -7
- data/lib/active_support/core_ext/hash/except.rb +8 -1
- data/lib/active_support/core_ext/hash/indifferent_access.rb +5 -0
- data/lib/active_support/core_ext/hash/keys.rb +10 -11
- data/lib/active_support/core_ext/hash/slice.rb +6 -0
- data/lib/active_support/core_ext/integer.rb +1 -1
- data/lib/active_support/core_ext/integer/multiple.rb +6 -0
- data/lib/active_support/core_ext/kernel.rb +1 -1
- data/lib/active_support/core_ext/kernel/debugger.rb +3 -2
- data/lib/active_support/core_ext/kernel/reporting.rb +2 -1
- data/lib/active_support/core_ext/kernel/requires.rb +2 -2
- data/lib/active_support/core_ext/kernel/singleton_class.rb +13 -0
- data/lib/active_support/core_ext/load_error.rb +17 -30
- data/lib/active_support/core_ext/logger.rb +2 -40
- data/lib/active_support/core_ext/module.rb +5 -3
- data/lib/active_support/core_ext/module/aliasing.rb +1 -1
- data/lib/active_support/core_ext/module/anonymous.rb +24 -0
- data/lib/active_support/core_ext/module/attr_accessor_with_default.rb +1 -1
- data/lib/active_support/core_ext/module/attr_internal.rb +2 -2
- data/lib/active_support/core_ext/module/attribute_accessors.rb +20 -22
- data/lib/active_support/core_ext/module/delegation.rb +21 -10
- data/lib/active_support/core_ext/module/introspection.rb +8 -8
- data/lib/active_support/core_ext/module/method_names.rb +14 -0
- data/lib/active_support/core_ext/module/reachable.rb +10 -0
- data/lib/active_support/core_ext/module/remove_method.rb +11 -0
- data/lib/active_support/core_ext/module/synchronization.rb +2 -1
- data/lib/active_support/core_ext/name_error.rb +3 -1
- data/lib/active_support/core_ext/object.rb +5 -3
- data/lib/active_support/core_ext/object/blank.rb +20 -2
- data/lib/active_support/core_ext/object/conversions.rb +2 -16
- data/lib/active_support/core_ext/object/duplicable.rb +23 -1
- data/lib/active_support/core_ext/object/instance_variables.rb +0 -7
- data/lib/active_support/core_ext/object/to_json.rb +19 -0
- data/lib/active_support/core_ext/object/to_param.rb +49 -0
- data/lib/active_support/core_ext/object/to_query.rb +27 -0
- data/lib/active_support/core_ext/object/with_options.rb +2 -0
- data/lib/active_support/core_ext/proc.rb +4 -4
- data/lib/active_support/core_ext/range/overlaps.rb +1 -1
- data/lib/active_support/core_ext/regexp.rb +0 -22
- data/lib/active_support/core_ext/rexml.rb +4 -1
- data/lib/active_support/core_ext/string.rb +3 -2
- data/lib/active_support/core_ext/string/access.rb +4 -2
- data/lib/active_support/core_ext/string/conversions.rb +28 -1
- data/lib/active_support/core_ext/string/encoding.rb +11 -0
- data/lib/active_support/core_ext/string/exclude.rb +6 -0
- data/lib/active_support/core_ext/string/filters.rb +29 -0
- data/lib/active_support/core_ext/string/inflections.rb +12 -12
- data/lib/active_support/core_ext/string/interpolation.rb +2 -92
- data/lib/active_support/core_ext/string/multibyte.rb +16 -19
- data/lib/active_support/core_ext/string/output_safety.rb +101 -35
- data/lib/active_support/core_ext/string/starts_ends_with.rb +0 -14
- data/lib/active_support/core_ext/string/xchar.rb +1 -1
- data/lib/active_support/core_ext/time/calculations.rb +14 -7
- data/lib/active_support/core_ext/time/conversions.rb +1 -0
- data/lib/active_support/core_ext/time/marshal.rb +56 -0
- data/lib/active_support/core_ext/time/zones.rb +2 -5
- data/lib/active_support/core_ext/uri.rb +10 -4
- data/lib/active_support/dependencies.rb +200 -197
- data/lib/active_support/dependencies/autoload.rb +50 -0
- data/lib/active_support/deprecation/behaviors.rb +13 -9
- data/lib/active_support/deprecation/method_wrappers.rb +10 -9
- data/lib/active_support/deprecation/proxy_wrappers.rb +7 -0
- data/lib/active_support/deprecation/reporting.rb +5 -3
- data/lib/active_support/descendants_tracker.rb +43 -0
- data/lib/active_support/duration.rb +8 -4
- data/lib/active_support/file_update_checker.rb +36 -0
- data/lib/active_support/hash_with_indifferent_access.rb +9 -1
- data/lib/active_support/i18n.rb +9 -0
- data/lib/active_support/i18n_railtie.rb +81 -0
- data/lib/active_support/inflections.rb +1 -1
- data/lib/active_support/inflector.rb +4 -407
- data/lib/active_support/inflector/inflections.rb +211 -0
- data/lib/active_support/inflector/methods.rb +151 -0
- data/lib/active_support/inflector/transliterate.rb +97 -0
- data/lib/active_support/json/backends/jsongem.rb +12 -9
- data/lib/active_support/json/backends/yajl.rb +40 -0
- data/lib/active_support/json/backends/yaml.rb +1 -1
- data/lib/active_support/json/decoding.rb +17 -2
- data/lib/active_support/json/encoding.rb +48 -31
- data/lib/active_support/json/variable.rb +2 -4
- data/lib/active_support/lazy_load_hooks.rb +27 -0
- data/lib/active_support/locale/en.yml +5 -2
- data/lib/active_support/log_subscriber.rb +123 -0
- data/lib/active_support/log_subscriber/test_helper.rb +99 -0
- data/lib/active_support/memoizable.rb +1 -1
- data/lib/active_support/message_encryptor.rb +1 -0
- data/lib/active_support/message_verifier.rb +2 -1
- data/lib/active_support/multibyte.rb +8 -23
- data/lib/active_support/multibyte/chars.rb +213 -446
- data/lib/active_support/multibyte/unicode.rb +392 -0
- data/lib/active_support/multibyte/utils.rb +6 -7
- data/lib/active_support/notifications.rb +29 -122
- data/lib/active_support/notifications/fanout.rb +61 -0
- data/lib/active_support/notifications/instrumenter.rb +54 -0
- data/lib/active_support/ordered_hash.rb +59 -14
- data/lib/active_support/ordered_options.rb +6 -0
- data/lib/active_support/railtie.rb +60 -0
- data/lib/active_support/rescuable.rb +7 -4
- data/lib/active_support/ruby/shim.rb +4 -6
- data/lib/active_support/test_case.rb +2 -7
- data/lib/active_support/testing/assertions.rb +15 -0
- data/lib/active_support/testing/declarative.rb +1 -1
- data/lib/active_support/testing/isolation.rb +64 -17
- data/lib/active_support/testing/performance.rb +306 -335
- data/lib/active_support/testing/setup_and_teardown.rb +51 -29
- data/lib/active_support/time.rb +24 -3
- data/lib/active_support/time_with_zone.rb +10 -14
- data/lib/active_support/values/time_zone.rb +192 -234
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/version.rb +3 -2
- data/lib/active_support/whiny_nil.rb +9 -7
- data/lib/active_support/xml_mini.rb +130 -1
- data/lib/active_support/xml_mini/jdom.rb +2 -0
- data/lib/active_support/xml_mini/libxml.rb +23 -86
- data/lib/active_support/xml_mini/libxmlsax.rb +85 -0
- data/lib/active_support/xml_mini/nokogiri.rb +27 -24
- data/lib/active_support/xml_mini/nokogirisax.rb +83 -0
- data/lib/active_support/xml_mini/rexml.rb +8 -2
- metadata +62 -195
- data/README +0 -43
- data/lib/active_support/autoload.rb +0 -28
- data/lib/active_support/core_ext/boolean.rb +0 -1
- data/lib/active_support/core_ext/boolean/conversions.rb +0 -11
- data/lib/active_support/core_ext/class/removal.rb +0 -53
- data/lib/active_support/core_ext/date.rb +0 -7
- data/lib/active_support/core_ext/date_time.rb +0 -5
- data/lib/active_support/core_ext/integer/even_odd.rb +0 -16
- data/lib/active_support/core_ext/kernel/daemonizing.rb +0 -7
- data/lib/active_support/core_ext/module/inclusion.rb +0 -30
- data/lib/active_support/core_ext/module/loading.rb +0 -23
- data/lib/active_support/core_ext/nil.rb +0 -1
- data/lib/active_support/core_ext/nil/conversions.rb +0 -5
- data/lib/active_support/core_ext/object/extending.rb +0 -80
- data/lib/active_support/core_ext/object/metaclass.rb +0 -13
- data/lib/active_support/core_ext/object/misc.rb +0 -3
- data/lib/active_support/core_ext/object/returning.rb +0 -42
- data/lib/active_support/core_ext/object/tap.rb +0 -16
- data/lib/active_support/core_ext/string/bytesize.rb +0 -5
- data/lib/active_support/core_ext/string/iterators.rb +0 -13
- data/lib/active_support/core_ext/symbol.rb +0 -1
- data/lib/active_support/core_ext/symbol/to_proc.rb +0 -14
- data/lib/active_support/core_ext/time.rb +0 -10
- data/lib/active_support/core_ext/time/marshal_with_utc_flag.rb +0 -22
- data/lib/active_support/deprecated_callbacks.rb +0 -283
- data/lib/active_support/multibyte/unicode_database.rb +0 -71
- data/lib/active_support/vendor.rb +0 -16
- data/lib/active_support/vendor/builder-2.1.2/lib/blankslate.rb +0 -113
- data/lib/active_support/vendor/builder-2.1.2/lib/builder.rb +0 -13
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/blankslate.rb +0 -20
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/css.rb +0 -250
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xchar.rb +0 -115
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlbase.rb +0 -139
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlevents.rb +0 -63
- data/lib/active_support/vendor/builder-2.1.2/lib/builder/xmlmarkup.rb +0 -328
- data/lib/active_support/vendor/i18n-0.1.3/MIT-LICENSE +0 -20
- data/lib/active_support/vendor/i18n-0.1.3/README.textile +0 -20
- data/lib/active_support/vendor/i18n-0.1.3/Rakefile +0 -5
- data/lib/active_support/vendor/i18n-0.1.3/i18n.gemspec +0 -27
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb +0 -204
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb +0 -215
- data/lib/active_support/vendor/i18n-0.1.3/lib/i18n/exceptions.rb +0 -53
- data/lib/active_support/vendor/i18n-0.1.3/test/all.rb +0 -5
- data/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb +0 -99
- data/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb +0 -124
- data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.rb +0 -1
- data/lib/active_support/vendor/i18n-0.1.3/test/locale/en.yml +0 -3
- data/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb +0 -567
- data/lib/active_support/vendor/memcache-client-1.7.5/lib/memcache.rb +0 -1133
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo.rb +0 -33
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone.rb +0 -47
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/data_timezone_info.rb +0 -228
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Algiers.rb +0 -55
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Cairo.rb +0 -219
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Casablanca.rb +0 -42
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Harare.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Johannesburg.rb +0 -25
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Monrovia.rb +0 -22
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Africa/Nairobi.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/Buenos_Aires.rb +0 -166
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Argentina/San_Juan.rb +0 -86
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Bogota.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Caracas.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chicago.rb +0 -283
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Chihuahua.rb +0 -136
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Denver.rb +0 -204
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Godthab.rb +0 -161
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Guatemala.rb +0 -27
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Halifax.rb +0 -274
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Indiana/Indianapolis.rb +0 -149
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Juneau.rb +0 -194
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/La_Paz.rb +0 -22
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Lima.rb +0 -35
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Los_Angeles.rb +0 -232
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mazatlan.rb +0 -139
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Mexico_City.rb +0 -144
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Monterrey.rb +0 -131
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/New_York.rb +0 -282
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Phoenix.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Regina.rb +0 -74
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Santiago.rb +0 -205
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Sao_Paulo.rb +0 -171
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/St_Johns.rb +0 -288
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/America/Tijuana.rb +0 -196
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Almaty.rb +0 -67
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baghdad.rb +0 -73
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Baku.rb +0 -161
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Bangkok.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Chongqing.rb +0 -33
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Colombo.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Dhaka.rb +0 -27
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Hong_Kong.rb +0 -87
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Irkutsk.rb +0 -165
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jakarta.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Jerusalem.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kabul.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kamchatka.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Karachi.rb +0 -32
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kathmandu.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kolkata.rb +0 -25
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Krasnoyarsk.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuala_Lumpur.rb +0 -31
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Kuwait.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Magadan.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Muscat.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Novosibirsk.rb +0 -164
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Rangoon.rb +0 -24
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Riyadh.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Seoul.rb +0 -34
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Shanghai.rb +0 -35
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Singapore.rb +0 -33
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Taipei.rb +0 -59
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tashkent.rb +0 -47
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tbilisi.rb +0 -78
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tehran.rb +0 -121
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Tokyo.rb +0 -30
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Ulaanbaatar.rb +0 -65
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Urumqi.rb +0 -33
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Vladivostok.rb +0 -164
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yakutsk.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yekaterinburg.rb +0 -165
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Asia/Yerevan.rb +0 -165
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Azores.rb +0 -270
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/Cape_Verde.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Atlantic/South_Georgia.rb +0 -18
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Adelaide.rb +0 -187
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Brisbane.rb +0 -35
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Darwin.rb +0 -29
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Hobart.rb +0 -193
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Melbourne.rb +0 -185
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Perth.rb +0 -37
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Australia/Sydney.rb +0 -185
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Etc/UTC.rb +0 -16
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Amsterdam.rb +0 -228
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Athens.rb +0 -185
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Belgrade.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Berlin.rb +0 -188
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bratislava.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Brussels.rb +0 -232
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Bucharest.rb +0 -181
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Budapest.rb +0 -197
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Copenhagen.rb +0 -179
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Dublin.rb +0 -276
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Helsinki.rb +0 -163
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Istanbul.rb +0 -218
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Kiev.rb +0 -168
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Lisbon.rb +0 -268
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Ljubljana.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/London.rb +0 -288
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Madrid.rb +0 -211
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Minsk.rb +0 -170
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Moscow.rb +0 -181
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Paris.rb +0 -232
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Prague.rb +0 -187
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Riga.rb +0 -176
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Rome.rb +0 -215
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sarajevo.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Skopje.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Sofia.rb +0 -173
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Stockholm.rb +0 -165
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Tallinn.rb +0 -172
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vienna.rb +0 -183
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Vilnius.rb +0 -170
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Warsaw.rb +0 -212
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Europe/Zagreb.rb +0 -13
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Auckland.rb +0 -202
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Fiji.rb +0 -23
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Guam.rb +0 -22
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Honolulu.rb +0 -28
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Majuro.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Midway.rb +0 -25
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Noumea.rb +0 -25
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Pago_Pago.rb +0 -26
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Port_Moresby.rb +0 -20
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/definitions/Pacific/Tongatapu.rb +0 -27
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/info_timezone.rb +0 -52
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone.rb +0 -51
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/linked_timezone_info.rb +0 -44
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/offset_rationals.rb +0 -98
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/ruby_core_support.rb +0 -56
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/time_or_datetime.rb +0 -292
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone.rb +0 -508
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_definition.rb +0 -56
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_info.rb +0 -40
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_offset_info.rb +0 -94
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_period.rb +0 -198
- data/lib/active_support/vendor/tzinfo-0.3.13/lib/tzinfo/timezone_transition_info.rb +0 -129
@@ -1,450 +1,421 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require '
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
:
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
1
|
+
begin
|
2
|
+
require 'ruby-prof'
|
3
|
+
|
4
|
+
require 'fileutils'
|
5
|
+
require 'rails/version'
|
6
|
+
require 'active_support/core_ext/class/delegating_attributes'
|
7
|
+
require 'active_support/core_ext/string/inflections'
|
8
|
+
|
9
|
+
module ActiveSupport
|
10
|
+
module Testing
|
11
|
+
module Performance
|
12
|
+
DEFAULTS =
|
13
|
+
if benchmark = ARGV.include?('--benchmark') # HAX for rake test
|
14
|
+
{ :benchmark => true,
|
15
|
+
:runs => 4,
|
16
|
+
:metrics => [:wall_time, :memory, :objects, :gc_runs, :gc_time],
|
17
|
+
:output => 'tmp/performance' }
|
18
|
+
else
|
19
|
+
{ :benchmark => false,
|
20
|
+
:runs => 1,
|
21
|
+
:min_percent => 0.01,
|
22
|
+
:metrics => [:process_time, :memory, :objects],
|
23
|
+
:formats => [:flat, :graph_html, :call_tree],
|
24
|
+
:output => 'tmp/performance' }
|
25
|
+
end.freeze
|
26
|
+
|
27
|
+
def self.included(base)
|
28
|
+
base.superclass_delegating_accessor :profile_options
|
29
|
+
base.profile_options = DEFAULTS
|
30
|
+
end
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
+
def full_test_name
|
33
|
+
"#{self.class.name}##{method_name}"
|
34
|
+
end
|
32
35
|
|
33
|
-
|
34
|
-
|
36
|
+
def run(result)
|
37
|
+
return if method_name =~ /^default_test$/
|
35
38
|
|
36
|
-
|
37
|
-
|
39
|
+
yield(self.class::STARTED, name)
|
40
|
+
@_result = result
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
run_warmup
|
43
|
+
if profile_options && metrics = profile_options[:metrics]
|
44
|
+
metrics.each do |metric_name|
|
45
|
+
if klass = Metrics[metric_name.to_sym]
|
46
|
+
run_profile(klass.new)
|
47
|
+
result.add_run
|
48
|
+
end
|
45
49
|
end
|
46
50
|
end
|
47
|
-
end
|
48
51
|
|
49
|
-
|
50
|
-
|
52
|
+
yield(self.class::FINISHED, name)
|
53
|
+
end
|
51
54
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
rescue ::Test::Unit::AssertionFailedError => e
|
57
|
-
add_failure(e.message, e.backtrace)
|
58
|
-
rescue StandardError, ScriptError
|
59
|
-
add_error($!)
|
60
|
-
ensure
|
61
|
-
begin
|
62
|
-
teardown
|
63
|
-
run_callbacks :teardown, :enumerator => :reverse_each
|
55
|
+
def run_test(metric, mode)
|
56
|
+
run_callbacks :setup
|
57
|
+
setup
|
58
|
+
metric.send(mode) { __send__ @method_name }
|
64
59
|
rescue ::Test::Unit::AssertionFailedError => e
|
65
60
|
add_failure(e.message, e.backtrace)
|
66
61
|
rescue StandardError, ScriptError
|
67
62
|
add_error($!)
|
63
|
+
ensure
|
64
|
+
begin
|
65
|
+
teardown
|
66
|
+
run_callbacks :teardown, :enumerator => :reverse_each
|
67
|
+
rescue ::Test::Unit::AssertionFailedError => e
|
68
|
+
add_failure(e.message, e.backtrace)
|
69
|
+
rescue StandardError, ScriptError
|
70
|
+
add_error($!)
|
71
|
+
end
|
68
72
|
end
|
69
|
-
end
|
70
|
-
|
71
|
-
protected
|
72
|
-
def run_warmup
|
73
|
-
GC.start
|
74
73
|
|
75
|
-
|
76
|
-
|
77
|
-
|
74
|
+
protected
|
75
|
+
def run_warmup
|
76
|
+
GC.start
|
78
77
|
|
79
|
-
|
80
|
-
|
78
|
+
time = Metrics::Time.new
|
79
|
+
run_test(time, :benchmark)
|
80
|
+
puts "%s (%s warmup)" % [full_test_name, time.format(time.total)]
|
81
81
|
|
82
|
-
|
83
|
-
|
84
|
-
performer = klass.new(self, metric)
|
82
|
+
GC.start
|
83
|
+
end
|
85
84
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
end
|
85
|
+
def run_profile(metric)
|
86
|
+
klass = profile_options[:benchmark] ? Benchmarker : Profiler
|
87
|
+
performer = klass.new(self, metric)
|
90
88
|
|
91
|
-
|
92
|
-
|
89
|
+
performer.run
|
90
|
+
puts performer.report
|
91
|
+
performer.record
|
92
|
+
end
|
93
93
|
|
94
|
-
|
95
|
-
|
96
|
-
end
|
94
|
+
class Performer
|
95
|
+
delegate :run_test, :profile_options, :full_test_name, :to => :@harness
|
97
96
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
end
|
97
|
+
def initialize(harness, metric)
|
98
|
+
@harness, @metric = harness, metric
|
99
|
+
end
|
102
100
|
|
103
|
-
|
104
|
-
|
105
|
-
|
101
|
+
def report
|
102
|
+
rate = @total / profile_options[:runs]
|
103
|
+
'%20s: %s' % [@metric.name, @metric.format(rate)]
|
106
104
|
end
|
107
|
-
end
|
108
105
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
106
|
+
protected
|
107
|
+
def output_filename
|
108
|
+
"#{profile_options[:output]}/#{full_test_name}_#{@metric.name}"
|
109
|
+
end
|
113
110
|
end
|
114
111
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
file.puts "#{avg},#{now},#{environment}"
|
112
|
+
class Benchmarker < Performer
|
113
|
+
def run
|
114
|
+
profile_options[:runs].to_i.times { run_test(@metric, :benchmark) }
|
115
|
+
@total = @metric.total
|
120
116
|
end
|
121
|
-
end
|
122
117
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
if File.directory?('vendor/rails/.git')
|
129
|
-
Dir.chdir('vendor/rails') do
|
130
|
-
rails += ".#{$1}.#{$2}" if `git branch -v` =~ /^\* (\S+)\s+(\S+)/
|
131
|
-
end
|
118
|
+
def record
|
119
|
+
avg = @metric.total / profile_options[:runs].to_i
|
120
|
+
now = Time.now.utc.xmlschema
|
121
|
+
with_output_file do |file|
|
122
|
+
file.puts "#{avg},#{now},#{environment}"
|
132
123
|
end
|
133
|
-
|
134
|
-
ruby = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
|
135
|
-
ruby += "-#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}"
|
136
|
-
|
137
|
-
@env = [app, rails, ruby, RUBY_PLATFORM] * ','
|
138
124
|
end
|
139
125
|
|
140
|
-
|
141
|
-
|
126
|
+
def environment
|
127
|
+
unless defined? @env
|
128
|
+
app = "#{$1}.#{$2}" if File.directory?('.git') && `git branch -v` =~ /^\* (\S+)\s+(\S+)/
|
142
129
|
|
143
|
-
|
144
|
-
|
130
|
+
rails = Rails::VERSION::STRING
|
131
|
+
if File.directory?('vendor/rails/.git')
|
132
|
+
Dir.chdir('vendor/rails') do
|
133
|
+
rails += ".#{$1}.#{$2}" if `git branch -v` =~ /^\* (\S+)\s+(\S+)/
|
134
|
+
end
|
135
|
+
end
|
145
136
|
|
146
|
-
|
147
|
-
|
137
|
+
ruby = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
|
138
|
+
ruby += "-#{RUBY_VERSION}.#{RUBY_PATCHLEVEL}"
|
148
139
|
|
149
|
-
|
150
|
-
FileUtils.mkdir_p(File.dirname(fname))
|
140
|
+
@env = [app, rails, ruby, RUBY_PLATFORM] * ','
|
151
141
|
end
|
152
142
|
|
153
|
-
|
154
|
-
file.puts(HEADER) if new
|
155
|
-
yield file
|
156
|
-
end
|
143
|
+
@env
|
157
144
|
end
|
158
145
|
|
159
|
-
|
160
|
-
|
161
|
-
end
|
162
|
-
end
|
146
|
+
protected
|
147
|
+
HEADER = 'measurement,created_at,app,rails,ruby,platform'
|
163
148
|
|
164
|
-
|
165
|
-
|
166
|
-
super
|
167
|
-
@supported = @metric.measure_mode rescue false
|
168
|
-
end
|
149
|
+
def with_output_file
|
150
|
+
fname = output_filename
|
169
151
|
|
170
|
-
|
171
|
-
|
152
|
+
if new = !File.exist?(fname)
|
153
|
+
FileUtils.mkdir_p(File.dirname(fname))
|
154
|
+
end
|
172
155
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
156
|
+
File.open(fname, 'ab') do |file|
|
157
|
+
file.puts(HEADER) if new
|
158
|
+
yield file
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def output_filename
|
163
|
+
"#{super}.csv"
|
164
|
+
end
|
179
165
|
end
|
180
166
|
|
181
|
-
|
182
|
-
|
167
|
+
class Profiler < Performer
|
168
|
+
def initialize(*args)
|
183
169
|
super
|
184
|
-
|
185
|
-
'%20s: unsupported' % @metric.name
|
170
|
+
@supported = @metric.measure_mode rescue false
|
186
171
|
end
|
187
|
-
end
|
188
172
|
|
189
|
-
|
190
|
-
|
173
|
+
def run
|
174
|
+
return unless @supported
|
191
175
|
|
192
|
-
|
176
|
+
RubyProf.measure_mode = @metric.measure_mode
|
177
|
+
RubyProf.start
|
178
|
+
RubyProf.pause
|
179
|
+
profile_options[:runs].to_i.times { run_test(@metric, :profile) }
|
180
|
+
@data = RubyProf.stop
|
181
|
+
@total = @data.threads.values.sum(0) { |method_infos| method_infos.sort.last.total_time }
|
182
|
+
end
|
193
183
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
184
|
+
def report
|
185
|
+
if @supported
|
186
|
+
super
|
187
|
+
else
|
188
|
+
'%20s: unsupported' % @metric.name
|
199
189
|
end
|
200
190
|
end
|
201
|
-
end
|
202
191
|
|
203
|
-
|
204
|
-
|
205
|
-
suffix =
|
206
|
-
case printer_class.name.demodulize
|
207
|
-
when 'FlatPrinter'; 'flat.txt'
|
208
|
-
when 'GraphPrinter'; 'graph.txt'
|
209
|
-
when 'GraphHtmlPrinter'; 'graph.html'
|
210
|
-
when 'CallTreePrinter'; 'tree.txt'
|
211
|
-
else printer_class.name.sub(/Printer$/, '').underscore
|
212
|
-
end
|
192
|
+
def record
|
193
|
+
return unless @supported
|
213
194
|
|
214
|
-
|
195
|
+
klasses = profile_options[:formats].map { |f| RubyProf.const_get("#{f.to_s.camelize}Printer") }.compact
|
196
|
+
|
197
|
+
klasses.each do |klass|
|
198
|
+
fname = output_filename(klass)
|
199
|
+
FileUtils.mkdir_p(File.dirname(fname))
|
200
|
+
File.open(fname, 'wb') do |file|
|
201
|
+
klass.new(@data).print(file, profile_options.slice(:min_percent))
|
202
|
+
end
|
203
|
+
end
|
215
204
|
end
|
216
|
-
end
|
217
205
|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
206
|
+
protected
|
207
|
+
def output_filename(printer_class)
|
208
|
+
suffix =
|
209
|
+
case printer_class.name.demodulize
|
210
|
+
when 'FlatPrinter'; 'flat.txt'
|
211
|
+
when 'GraphPrinter'; 'graph.txt'
|
212
|
+
when 'GraphHtmlPrinter'; 'graph.html'
|
213
|
+
when 'CallTreePrinter'; 'tree.txt'
|
214
|
+
else printer_class.name.sub(/Printer$/, '').underscore
|
215
|
+
end
|
216
|
+
|
217
|
+
"#{super()}_#{suffix}"
|
218
|
+
end
|
223
219
|
end
|
224
220
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
221
|
+
module Metrics
|
222
|
+
def self.[](name)
|
223
|
+
const_get(name.to_s.camelize)
|
224
|
+
rescue NameError
|
225
|
+
nil
|
230
226
|
end
|
231
227
|
|
232
|
-
|
233
|
-
|
234
|
-
end
|
228
|
+
class Base
|
229
|
+
attr_reader :total
|
235
230
|
|
236
|
-
|
237
|
-
|
238
|
-
|
231
|
+
def initialize
|
232
|
+
@total = 0
|
233
|
+
end
|
239
234
|
|
240
|
-
|
241
|
-
|
242
|
-
|
235
|
+
def name
|
236
|
+
@name ||= self.class.name.demodulize.underscore
|
237
|
+
end
|
243
238
|
|
244
|
-
|
245
|
-
|
246
|
-
before = measure
|
247
|
-
yield
|
248
|
-
@total += (measure - before)
|
239
|
+
def measure_mode
|
240
|
+
self.class::Mode
|
249
241
|
end
|
250
|
-
end
|
251
242
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
ensure
|
256
|
-
RubyProf.pause
|
257
|
-
end
|
243
|
+
def measure
|
244
|
+
0
|
245
|
+
end
|
258
246
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
GC.enable_stats
|
263
|
-
yield
|
264
|
-
ensure
|
265
|
-
GC.disable_stats
|
266
|
-
end
|
267
|
-
elsif defined?(GC::Profiler)
|
268
|
-
def with_gc_stats
|
269
|
-
GC.start
|
270
|
-
GC.disable
|
271
|
-
GC::Profiler.enable
|
272
|
-
yield
|
273
|
-
ensure
|
274
|
-
GC::Profiler.disable
|
275
|
-
GC.enable
|
276
|
-
end
|
277
|
-
else
|
278
|
-
def with_gc_stats
|
247
|
+
def benchmark
|
248
|
+
with_gc_stats do
|
249
|
+
before = measure
|
279
250
|
yield
|
251
|
+
@total += (measure - before)
|
280
252
|
end
|
281
253
|
end
|
282
|
-
end
|
283
254
|
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
def format(measurement)
|
290
|
-
if measurement < 2
|
291
|
-
'%d ms' % (measurement * 1000)
|
292
|
-
else
|
293
|
-
'%.2f sec' % measurement
|
255
|
+
def profile
|
256
|
+
RubyProf.resume
|
257
|
+
yield
|
258
|
+
ensure
|
259
|
+
RubyProf.pause
|
294
260
|
end
|
295
|
-
end
|
296
|
-
end
|
297
261
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
262
|
+
protected
|
263
|
+
# Ruby 1.9 with GC::Profiler
|
264
|
+
if defined?(GC::Profiler)
|
265
|
+
def with_gc_stats
|
266
|
+
GC::Profiler.enable
|
267
|
+
GC.start
|
268
|
+
yield
|
269
|
+
ensure
|
270
|
+
GC::Profiler.disable
|
271
|
+
end
|
272
|
+
|
273
|
+
# Ruby 1.8 + ruby-prof wrapper (enable/disable stats for Benchmarker)
|
274
|
+
elsif GC.respond_to?(:enable_stats)
|
275
|
+
def with_gc_stats
|
276
|
+
GC.enable_stats
|
277
|
+
yield
|
278
|
+
ensure
|
279
|
+
GC.disable_stats
|
280
|
+
end
|
281
|
+
|
282
|
+
else
|
283
|
+
def with_gc_stats
|
284
|
+
yield
|
285
|
+
end
|
286
|
+
end
|
303
287
|
end
|
304
|
-
end
|
305
288
|
|
306
|
-
|
307
|
-
|
289
|
+
class Time < Base
|
290
|
+
def measure
|
291
|
+
::Time.now.to_f
|
292
|
+
end
|
308
293
|
|
309
|
-
|
310
|
-
|
294
|
+
def format(measurement)
|
295
|
+
if measurement < 1
|
296
|
+
'%d ms' % (measurement * 1000)
|
297
|
+
else
|
298
|
+
'%.2f sec' % measurement
|
299
|
+
end
|
300
|
+
end
|
311
301
|
end
|
312
|
-
end
|
313
302
|
|
314
|
-
|
315
|
-
|
303
|
+
class ProcessTime < Time
|
304
|
+
Mode = RubyProf::PROCESS_TIME
|
316
305
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
super
|
321
|
-
end
|
322
|
-
|
323
|
-
def measure
|
324
|
-
RubyProf.measure_cpu_time
|
306
|
+
def measure
|
307
|
+
RubyProf.measure_process_time
|
308
|
+
end
|
325
309
|
end
|
326
|
-
end
|
327
310
|
|
328
|
-
|
329
|
-
|
311
|
+
class WallTime < Time
|
312
|
+
Mode = RubyProf::WALL_TIME
|
330
313
|
|
331
|
-
# ruby-prof wrapper
|
332
|
-
if RubyProf.respond_to?(:measure_memory)
|
333
314
|
def measure
|
334
|
-
RubyProf.
|
315
|
+
RubyProf.measure_wall_time
|
335
316
|
end
|
317
|
+
end
|
336
318
|
|
337
|
-
|
338
|
-
|
339
|
-
def measure
|
340
|
-
GC.allocated_size / 1024.0
|
341
|
-
end
|
319
|
+
class CpuTime < Time
|
320
|
+
Mode = RubyProf::CPU_TIME if RubyProf.const_defined?(:CPU_TIME)
|
342
321
|
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
322
|
+
def initialize(*args)
|
323
|
+
# FIXME: yeah my CPU is 2.33 GHz
|
324
|
+
RubyProf.cpu_frequency = 2.33e9 unless RubyProf.cpu_frequency > 0
|
325
|
+
super
|
347
326
|
end
|
348
327
|
|
349
|
-
# Ruby 1.9 with total_malloc_allocated_size patch
|
350
|
-
elsif GC.respond_to?(:malloc_total_allocated_size)
|
351
328
|
def measure
|
352
|
-
|
329
|
+
RubyProf.measure_cpu_time
|
353
330
|
end
|
331
|
+
end
|
354
332
|
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
333
|
+
class Memory < Base
|
334
|
+
Mode = RubyProf::MEMORY if RubyProf.const_defined?(:MEMORY)
|
335
|
+
|
336
|
+
# Ruby 1.9 + GCdata patch
|
337
|
+
if GC.respond_to?(:malloc_allocated_size)
|
338
|
+
def measure
|
339
|
+
GC.malloc_allocated_size / 1024.0
|
340
|
+
end
|
341
|
+
|
342
|
+
# Ruby 1.8 + ruby-prof wrapper
|
343
|
+
elsif RubyProf.respond_to?(:measure_memory)
|
344
|
+
def measure
|
345
|
+
RubyProf.measure_memory / 1024.0
|
346
|
+
end
|
359
347
|
end
|
360
348
|
|
361
|
-
|
362
|
-
|
363
|
-
def measure
|
364
|
-
GC.enable
|
365
|
-
GC.start
|
366
|
-
kb = GC::Profiler.data.last[:HEAP_USE_SIZE] / 1024.0
|
367
|
-
GC.disable
|
368
|
-
kb
|
349
|
+
def format(measurement)
|
350
|
+
'%.2f KB' % measurement
|
369
351
|
end
|
370
352
|
end
|
371
353
|
|
372
|
-
|
373
|
-
|
374
|
-
end
|
375
|
-
end
|
354
|
+
class Objects < Base
|
355
|
+
Mode = RubyProf::ALLOCATIONS if RubyProf.const_defined?(:ALLOCATIONS)
|
376
356
|
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
RubyProf.measure_allocations
|
383
|
-
end
|
357
|
+
# Ruby 1.9 + GCdata patch
|
358
|
+
if GC.respond_to?(:malloc_allocations)
|
359
|
+
def measure
|
360
|
+
GC.malloc_allocations
|
361
|
+
end
|
384
362
|
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
363
|
+
# Ruby 1.8 + ruby-prof wrapper
|
364
|
+
elsif RubyProf.respond_to?(:measure_allocations)
|
365
|
+
def measure
|
366
|
+
RubyProf.measure_allocations
|
367
|
+
end
|
389
368
|
end
|
390
369
|
|
391
|
-
|
392
|
-
|
393
|
-
def measure
|
394
|
-
GC.enable
|
395
|
-
GC.start
|
396
|
-
last = GC::Profiler.data.last
|
397
|
-
count = last[:HEAP_LIVE_OBJECTS] + last[:HEAP_FREE_OBJECTS]
|
398
|
-
GC.disable
|
399
|
-
count
|
370
|
+
def format(measurement)
|
371
|
+
measurement.to_i.to_s
|
400
372
|
end
|
401
373
|
end
|
402
374
|
|
403
|
-
|
404
|
-
|
405
|
-
end
|
406
|
-
end
|
375
|
+
class GcRuns < Base
|
376
|
+
Mode = RubyProf::GC_RUNS if RubyProf.const_defined?(:GC_RUNS)
|
407
377
|
|
408
|
-
|
409
|
-
|
378
|
+
# Ruby 1.9
|
379
|
+
if GC.respond_to?(:count)
|
380
|
+
def measure
|
381
|
+
GC.count
|
382
|
+
end
|
410
383
|
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
def measure
|
417
|
-
GC.collections
|
384
|
+
# Ruby 1.8 + ruby-prof wrapper
|
385
|
+
elsif RubyProf.respond_to?(:measure_gc_runs)
|
386
|
+
def measure
|
387
|
+
RubyProf.measure_gc_runs
|
388
|
+
end
|
418
389
|
end
|
419
|
-
|
420
|
-
def
|
421
|
-
|
390
|
+
|
391
|
+
def format(measurement)
|
392
|
+
measurement.to_i.to_s
|
422
393
|
end
|
423
394
|
end
|
424
395
|
|
425
|
-
|
426
|
-
|
427
|
-
end
|
428
|
-
end
|
396
|
+
class GcTime < Base
|
397
|
+
Mode = RubyProf::GC_TIME if RubyProf.const_defined?(:GC_TIME)
|
429
398
|
|
430
|
-
|
431
|
-
|
399
|
+
# Ruby 1.9 with GC::Profiler
|
400
|
+
if GC.respond_to?(:total_time)
|
401
|
+
def measure
|
402
|
+
GC::Profiler.total_time
|
403
|
+
end
|
432
404
|
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
def measure
|
439
|
-
GC.time
|
405
|
+
# Ruby 1.8 + ruby-prof wrapper
|
406
|
+
elsif RubyProf.respond_to?(:measure_gc_time)
|
407
|
+
def measure
|
408
|
+
RubyProf.measure_gc_time / 1000
|
409
|
+
end
|
440
410
|
end
|
441
|
-
end
|
442
411
|
|
443
|
-
|
444
|
-
|
412
|
+
def format(measurement)
|
413
|
+
'%.2f ms' % measurement
|
414
|
+
end
|
445
415
|
end
|
446
416
|
end
|
447
417
|
end
|
448
418
|
end
|
449
419
|
end
|
420
|
+
rescue LoadError
|
450
421
|
end
|