Insert brief description of your app.
- Ruby 1.9.3+
- Bundler 1.3.0
- PostgreSQL
| i = Injector.new first: 'First Name', last: 'Last Name', power: 2 | |
| def full_name(first, last) | |
| "#{first} #{last}" | |
| end | |
| def random_to_power(power) | |
| 4 ** power | |
| end |
| 4 processes for 77 specs, ~ 19 specs per process | |
| .....DEPRECATION WARNING: Active Admin: ActiveAdmin.default_namespace is deprecated. Please use ActiveAdmin.application.default_namespace. (called from block (3 levels) in <top (required)> at /Users/goshakkk/Projects/active_admin/spec/unit/active_admin_spec.rb:8) | |
| .............................................................................Running JSLint: | |
| ......................***** | |
| No JS errors found. | |
| ..............................DEPRECATION WARNING: ActiveAdmin::Dashboard is deprecated and will be removed in the next version | |
| ...........................................................................................................................F*.....................................................*.........................................................................................*..*.......*............................................................*......... | |
| require 'benchmark' | |
| # Benchmarking Array#compact & Array#join | |
| n = 1_000_000 | |
| Benchmark.bm do |x| | |
| x.report('3 elements + nil') { n.times { ['a', 'b', 'c', nil].compact.join('::') } } | |
| x.report('3 elements') { n.times { ['a', 'b', 'c'].compact.join('::') } } | |
| end | |
| # user system total real |
| require 'benchmark' | |
| n = 1_000_000 | |
| Benchmark.bm do |x| | |
| x.report('[[1]]') { n.times { [[1]].flatten } } | |
| x.report('Array([1])') { n.times { Array([1]) } } | |
| x.report('[1]') { n.times { [1].flatten } } | |
| x.report('Array(1)') { n.times { Array(1) } } | |
| end |
| # Mongoid inline relation definitions. Ruby makes it so easy. | |
| # (`data` is effectively just a shortcut for `inline_embed_one(:data)` there.) | |
| # | |
| # Yes, it would make sense to create separate models, but my case is different. | |
| # This application is used to track events of other apps, such as purchase, and | |
| # it makes *more* sense to embed all order-related data. Instead of having model | |
| # overload for each event being tracked, I just define them inline. | |
| class OrderEvent | |
| include Analyzing::Event |
| 1000000 documents | |
| 249819 documents with non-empty 'search_query' | |
| user system total real | |
| simple map/reduce 0.270000 0.010000 0.280000 (353.701946) | |
| simple aggregation 0.180000 0.010000 0.190000 ( 8.049170) | |
| filtering map/reduce 0.250000 0.010000 0.260000 (337.955130) | |
| filtering aggregation 0.150000 0.010000 0.160000 ( 4.095468) |
| $ cat bm.rb | |
| require './env' | |
| Benchmark.bm do |x| | |
| x.report('block') { OrderEvent.all.limit(100_000).map(&:total) } | |
| x.report('sym') { OrderEvent.all.limit(100_000).map(:total) } | |
| end | |
| $ ruby bm.rb | |
| user system total real |
| sys_rb_usr=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr | |
| sdk_rb_usr=`xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr | |
| sudo cp -r $sdk_rb_usr/include $sys_rb_usr/include |