-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
It seems to have got quite slow. Not sure what is causing it as using Yajl directly doesn't seem to improve it much.
MongoDB: 2.0.6
Mongoid 3.0.0.rc
require 'mongoid' require 'benchmark' require 'yajl/json_gem' ENV['MONGOID_ENV'] = 'development' Mongoid.load!("config/mongoid.yml") class Facility include Mongoid::Document include Mongoid::Timestamps field :name, :type => String field :location, :type => String end @facilities = Facility.all.limit(50).entries Benchmark.bm do |x| x.report("Mongoid") { @a = @facilities.to_json } x.report("Parse ") { @b = JSON.parse(@a) } x.report("Encode ") { @b.to_json } x.report("Encode ") { Yajl::Encoder.encode(@facilities) } end
results
user system total real Mongoid 0.260000 0.000000 0.260000 ( 0.262572) Parse 0.020000 0.000000 0.020000 ( 0.021703) Encode 0.010000 0.000000 0.010000 ( 0.006516) Encode 0.220000 0.000000 0.220000 ( 0.238196)