json_pure 1.0.0 → 1.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +155 -1
- data/COPYING +58 -0
- data/GPL +7 -7
- data/README +324 -45
- data/Rakefile +166 -124
- data/TODO +1 -1
- data/VERSION +1 -1
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +52 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +900 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +901 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +261 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +262 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +82 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +34 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +900 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +901 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +81 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +82 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +82 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +1000 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +1001 -0
- data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +82 -0
- data/benchmarks/generator2_benchmark.rb +222 -0
- data/benchmarks/generator_benchmark.rb +224 -0
- data/benchmarks/ohai.json +1216 -0
- data/benchmarks/ohai.ruby +1 -0
- data/benchmarks/parser2_benchmark.rb +251 -0
- data/benchmarks/parser_benchmark.rb +259 -0
- data/bin/edit_json.rb +1 -3
- data/bin/prettify_json.rb +75 -0
- data/data/index.html +5 -4
- data/data/prototype.js +2764 -1095
- data/ext/json/ext/generator/extconf.rb +14 -3
- data/ext/json/ext/generator/generator.c +1022 -334
- data/ext/json/ext/generator/generator.h +197 -0
- data/ext/json/ext/parser/extconf.rb +9 -3
- data/ext/json/ext/parser/parser.c +961 -577
- data/ext/json/ext/parser/parser.h +71 -0
- data/ext/json/ext/parser/parser.rl +400 -123
- data/install.rb +0 -0
- data/lib/json/add/core.rb +148 -0
- data/lib/json/add/rails.rb +58 -0
- data/lib/json/common.rb +254 -47
- data/lib/json/editor.rb +236 -72
- data/lib/json/ext.rb +2 -0
- data/lib/json/pure/generator.rb +235 -117
- data/lib/json/pure/parser.rb +124 -25
- data/lib/json/pure.rb +5 -3
- data/lib/json/version.rb +1 -1
- data/lib/json.rb +2 -197
- data/tests/fixtures/fail18.json +1 -0
- data/tests/test_json.rb +181 -22
- data/tests/test_json_addition.rb +84 -16
- data/tests/test_json_encoding.rb +68 -0
- data/tests/test_json_fixtures.rb +9 -5
- data/tests/test_json_generate.rb +114 -14
- data/tests/test_json_rails.rb +144 -0
- data/tests/test_json_unicode.rb +35 -14
- data/tools/fuzz.rb +13 -7
- data/tools/server.rb +0 -1
- metadata +156 -122
- data/benchmarks/benchmark.txt +0 -133
- data/benchmarks/benchmark_generator.rb +0 -44
- data/benchmarks/benchmark_parser.rb +0 -22
- data/benchmarks/benchmark_rails.rb +0 -26
- data/ext/json/ext/generator/Makefile +0 -149
- data/ext/json/ext/generator/unicode.c +0 -184
- data/ext/json/ext/generator/unicode.h +0 -40
- data/ext/json/ext/parser/Makefile +0 -149
- data/ext/json/ext/parser/unicode.c +0 -156
- data/ext/json/ext/parser/unicode.h +0 -44
- data/tests/fixtures/pass18.json +0 -1
- data/tests/runner.rb +0 -24
- /data/tests/fixtures/{fail15.json → pass15.json} +0 -0
- /data/tests/fixtures/{fail16.json → pass16.json} +0 -0
- /data/tests/fixtures/{fail17.json → pass17.json} +0 -0
- /data/tests/fixtures/{fail26.json → pass26.json} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"kernel"=>{"name"=>"Darwin", "machine"=>"i386", "modules"=>{"com.apple.driver.AppleAPIC"=>{"size"=>12288, "version"=>"1.4", "index"=>"26", "refcount"=>"0"}, "com.apple.driver.AirPort.Atheros"=>{"size"=>593920, "version"=>"318.8.3", "index"=>"88", "refcount"=>"0"}, "com.apple.driver.AppleIntelCPUPowerManagement"=>{"size"=>102400, "version"=>"59.0.1", "index"=>"22", "refcount"=>"0"}, "com.apple.iokit.IOStorageFamily"=>{"size"=>98304, "version"=>"1.5.5", "index"=>"44", "refcount"=>"9"}, "com.apple.iokit.IOATAPIProtocolTransport"=>{"size"=>16384, "version"=>"1.5.2", "index"=>"52", "refcount"=>"0"}, "com.apple.iokit.IOPCIFamily"=>{"size"=>65536, "version"=>"2.5", "index"=>"17", "refcount"=>"18"}, "org.virtualbox.kext.VBoxDrv"=>{"size"=>118784, "version"=>"2.2.0", "index"=>"114", "refcount"=>"3"}, "com.cisco.nke.ipsec"=>{"size"=>454656, "version"=>"2.0.1", "index"=>"111", "refcount"=>"0"}, "com.apple.driver.AppleHPET"=>{"size"=>12288, "version"=>"1.3", "index"=>"33", "refcount"=>"0"}, "com.apple.driver.AppleUSBHub"=>{"size"=>49152, "version"=>"3.2.7", "index"=>"47", "refcount"=>"0"}, "com.apple.iokit.IOFireWireFamily"=>{"size"=>258048, "version"=>"3.4.6", "index"=>"49", "refcount"=>"2"}, "com.apple.driver.AppleUSBComposite"=>{"size"=>16384, "version"=>"3.2.0", "index"=>"60", "refcount"=>"1"}, "com.apple.driver.AppleIntelPIIXATA"=>{"size"=>36864, "version"=>"2.0.0", "index"=>"41", "refcount"=>"0"}, "com.apple.driver.AppleSmartBatteryManager"=>{"size"=>28672, "version"=>"158.6.0", "index"=>"32", "refcount"=>"0"}, "com.apple.filesystems.udf"=>{"size"=>233472, "version"=>"2.0.2", "index"=>"119", "refcount"=>"0"}, "com.apple.iokit.IOSMBusFamily"=>{"size"=>12288, "version"=>"1.1", "index"=>"27", "refcount"=>"2"}, "com.apple.iokit.IOACPIFamily"=>{"size"=>16384, "version"=>"1.2.0", "index"=>"18", "refcount"=>"10"}, "foo.tap"=>{"size"=>24576, "version"=>"1.0", "index"=>"113", "refcount"=>"0"}, "com.vmware.kext.vmx86"=>{"size"=>864256, "version"=>"2.0.4", "index"=>"104", "refcount"=>"0"}, "com.apple.iokit.CHUDUtils"=>{"size"=>28672, "version"=>"200", "index"=>"98", "refcount"=>"0"}, "com.apple.driver.AppleACPIButtons"=>{"size"=>16384, "version"=>"1.2.4", "index"=>"30", "refcount"=>"0"}, "com.apple.driver.AppleFWOHCI"=>{"size"=>139264, "version"=>"3.7.2", "index"=>"50", "refcount"=>"0"}, "com.apple.iokit.IOSCSIArchitectureModelFamily"=>{"size"=>102400, "version"=>"2.0.5", "index"=>"51", "refcount"=>"4"}, "org.virtualbox.kext.VBoxNetAdp"=>{"size"=>8192, "version"=>"2.2.0", "index"=>"117", "refcount"=>"0"}, "com.apple.filesystems.autofs"=>{"size"=>45056, "version"=>"2.0.1", "index"=>"109", "refcount"=>"0"}, "com.vmware.kext.vmnet"=>{"size"=>36864, "version"=>"2.0.4", "index"=>"108", "refcount"=>"0"}, "com.apple.iokit.IOSCSIBlockCommandsDevice"=>{"size"=>90112, "version"=>"2.0.5", "index"=>"57", "refcount"=>"1"}, "com.apple.driver.AppleACPIPCI"=>{"size"=>12288, "version"=>"1.2.4", "index"=>"31", "refcount"=>"0"}, "com.apple.security.seatbelt"=>{"size"=>98304, "version"=>"107.10", "index"=>"25", "refcount"=>"0"}, "com.apple.driver.AppleUpstreamUserClient"=>{"size"=>16384, "version"=>"2.7.2", "index"=>"100", "refcount"=>"0"}, "com.apple.kext.OSvKernDSPLib"=>{"size"=>12288, "version"=>"1.1", "index"=>"79", "refcount"=>"1"}, "com.apple.iokit.IOBDStorageFamily"=>{"size"=>20480, "version"=>"1.5", "index"=>"58", "refcount"=>"1"}, "com.apple.iokit.IOGraphicsFamily"=>{"size"=>118784, "version"=>"1.7.1", "index"=>"70", "refcount"=>"5"}, "com.apple.iokit.IONetworkingFamily"=>{"size"=>90112, "version"=>"1.6.1", "index"=>"82", "refcount"=>"4"}, "com.apple.iokit.IOATAFamily"=>{"size"=>53248, "version"=>"2.0.0", "index"=>"40", "refcount"=>"2"}, "com.apple.iokit.IOUSBHIDDriver"=>{"size"=>20480, "version"=>"3.2.2", "index"=>"63", "refcount"=>"2"}, "org.virtualbox.kext.VBoxUSB"=>{"size"=>28672, "version"=>"2.2.0", "index"=>"115", "refcount"=>"0"}, "com.apple.security.TMSafetyNet"=>{"size"=>12288, "version"=>"3", "index"=>"23", "refcount"=>"0"}, "com.apple.iokit.IONDRVSupport"=>{"size"=>57344, "version"=>"1.7.1", "index"=>"71", "refcount"=>"3"}, "com.apple.BootCache"=>{"size"=>20480, "version"=>"30.3", "index"=>"20", "refcount"=>"0"}, "com.vmware.kext.vmioplug"=>{"size"=>24576, "version"=>"2.0.4", "index"=>"107", "refcount"=>"0"}, "com.apple.iokit.IOUSBUserClient"=>{"size"=>8192, "version"=>"3.2.4", "index"=>"46", "refcount"=>"1"}, "com.apple.iokit.IOSCSIMultimediaCommandsDevice"=>{"size"=>90112, "version"=>"2.0.5", "index"=>"59", "refcount"=>"0"}, "com.apple.driver.AppleIRController"=>{"size"=>20480, "version"=>"110", "index"=>"78", "refcount"=>"0"}, "com.apple.driver.AudioIPCDriver"=>{"size"=>16384, "version"=>"1.0.5", "index"=>"81", "refcount"=>"0"}, "com.apple.driver.AppleLPC"=>{"size"=>12288, "version"=>"1.2.11", "index"=>"73", "refcount"=>"0"}, "org.virtualbox.kext.VBoxNetFlt"=>{"size"=>16384, "version"=>"2.2.0", "index"=>"116", "refcount"=>"0"}, "com.apple.iokit.CHUDKernLib"=>{"size"=>20480, "version"=>"196", "index"=>"93", "refcount"=>"2"}, "com.apple.iokit.CHUDProf"=>{"size"=>49152, "version"=>"207", "index"=>"97", "refcount"=>"0"}, "com.apple.NVDAResman"=>{"size"=>2478080, "version"=>"5.3.6", "index"=>"90", "refcount"=>"2"}, "com.apple.driver.AppleACPIEC"=>{"size"=>20480, "version"=>"1.2.4", "index"=>"28", "refcount"=>"0"}, "foo.tun"=>{"size"=>24576, "version"=>"1.0", "index"=>"118", "refcount"=>"0"}, "com.apple.iokit.IOSerialFamily"=>{"size"=>36864, "version"=>"9.3", "index"=>"102", "refcount"=>"1"}, "com.apple.GeForce"=>{"size"=>622592, "version"=>"5.3.6", "index"=>"96", "refcount"=>"0"}, "com.apple.iokit.IOCDStorageFamily"=>{"size"=>32768, "version"=>"1.5", "index"=>"55", "refcount"=>"3"}, "com.apple.driver.AppleUSBEHCI"=>{"size"=>73728, "version"=>"3.2.5", "index"=>"39", "refcount"=>"0"}, "com.apple.nvidia.nv50hal"=>{"size"=>2445312, "version"=>"5.3.6", "index"=>"91", "refcount"=>"0"}, "com.apple.driver.AppleSMBIOS"=>{"size"=>16384, "version"=>"1.1.1", "index"=>"29", "refcount"=>"0"}, "com.apple.driver.AppleBacklight"=>{"size"=>16384, "version"=>"1.4.4", "index"=>"72", "refcount"=>"0"}, "com.apple.driver.AppleACPIPlatform"=>{"size"=>253952, "version"=>"1.2.4", "index"=>"19", "refcount"=>"3"}, "com.apple.iokit.SCSITaskUserClient"=>{"size"=>24576, "version"=>"2.0.5", "index"=>"54", "refcount"=>"0"}, "com.apple.iokit.IOHIDFamily"=>{"size"=>233472, "version"=>"1.5.3", "index"=>"21", "refcount"=>"7"}, "com.apple.driver.DiskImages"=>{"size"=>65536, "version"=>"195.2.2", "index"=>"101", "refcount"=>"0"}, "com.apple.iokit.IODVDStorageFamily"=>{"size"=>24576, "version"=>"1.5", "index"=>"56", "refcount"=>"2"}, "com.apple.iokit.IOFireWireIP"=>{"size"=>36864, "version"=>"1.7.6", "index"=>"83", "refcount"=>"0"}, "com.apple.driver.AppleRTC"=>{"size"=>20480, "version"=>"1.2.3", "index"=>"34", "refcount"=>"0"}, "com.apple.driver.XsanFilter"=>{"size"=>20480, "version"=>"2.7.91", "index"=>"53", "refcount"=>"0"}, "com.apple.driver.AppleEFIRuntime"=>{"size"=>12288, "version"=>"1.2.0", "index"=>"35", "refcount"=>"1"}, "com.apple.iokit.IOAHCIBlockStorage"=>{"size"=>69632, "version"=>"1.2.0", "index"=>"48", "refcount"=>"0"}, "com.apple.nke.applicationfirewall"=>{"size"=>32768, "version"=>"1.0.77", "index"=>"24", "refcount"=>"0"}, "com.apple.iokit.IO80211Family"=>{"size"=>126976, "version"=>"215.1", "index"=>"87", "refcount"=>"1"}, "com.vmware.kext.vmci"=>{"size"=>45056, "version"=>"2.0.4", "index"=>"106", "refcount"=>"0"}, "com.apple.iokit.IOAHCIFamily"=>{"size"=>24576, "version"=>"1.5.0", "index"=>"42", "refcount"=>"2"}, "com.apple.driver.AppleUSBUHCI"=>{"size"=>57344, "version"=>"3.2.5", "index"=>"38", "refcount"=>"0"}, "com.apple.driver.AppleUSBMergeNub"=>{"size"=>12288, "version"=>"3.2.4", "index"=>"61", "refcount"=>"0"}, "com.apple.iokit.IOUSBFamily"=>{"size"=>167936, "version"=>"3.2.7", "index"=>"37", "refcount"=>"13"}, "com.apple.driver.AppleEFINVRAM"=>{"size"=>24576, "version"=>"1.2.0", "index"=>"36", "refcount"=>"0"}, "com.apple.driver.AppleAHCIPort"=>{"size"=>53248, "version"=>"1.5.2", "index"=>"43", "refcount"=>"0"}}, "os"=>"Darwin", "version"=>"Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386", "release"=>"9.6.0"}, "command"=>{"ps"=>"ps -ef"}, "platform"=>"mac_os_x", "platform_version"=>"10.5.6", "keys"=>{"ssh"=>{"host_dsa_public"=>"private", "host_rsa_public"=>"private"}}, "ipaddress"=>"192.168.88.1", "fqdn"=>"local.local", "network"=>{"settings"=>{"net.inet6.ip6.forwarding"=>"0", "net.inet.ip.dummynet.debug"=>"0", "net.inet.ip.rtexpire"=>"10", "net.inet6.ipsec6.esp_trans_deflev"=>"1", "net.inet.tcp.tcbhashsize"=>"4096", "net.key.esp_auth"=>"0", "net.inet6.ip6.hlim"=>"64", "net.inet.ip.fw.dyn_fin_lifetime"=>"1", "net.inet.ip.fw.dyn_udp_lifetime"=>"10", "net.inet.icmp.bmcastecho"=>"1", "net.athbgscan"=>"1 1", "net.inet.tcp.reass.maxsegments"=>"2048", "net.athforceBias"=>"2 2", "net.inet6.ip6.auto_flowlabel"=>"1", "net.inet6.ip6.rtmaxcache"=>"128", "net.inet.tcp.sendspace"=>"131072", "net.inet.tcp.keepinit"=>"75000", "net.inet.ip.dummynet.max_chain_len"=>"16", "net.inet.tcp.rfc1644"=>"0", "net.inet.ip.fw.curr_dyn_buckets"=>"256", "net.inet.ip.dummynet.ready_heap"=>"0", "net.inet.ip.portrange.first"=>"49152", "net.inet.tcp.background_io_trigger"=>"5", "net.link.ether.inet.host_down_time"=>"20", "net.inet6.ipsec6.def_policy"=>"1", "net.inet6.ipsec6.ecn"=>"0", "net.inet.ip.fastforwarding"=>"0", "net.inet6.ip6.v6only"=>"0", "net.inet.tcp.sack"=>"1", "net.inet6.ip6.rtexpire"=>"3600", "net.link.ether.inet.proxyall"=>"0", "net.athaddbaignore"=>"0 0", "net.inet6.ip6.keepfaith"=>"0", "net.key.spi_trycnt"=>"1000", "net.link.ether.inet.prune_intvl"=>"300", "net.inet.tcp.ecn_initiate_out"=>"0", "net.inet.ip.fw.dyn_rst_lifetime"=>"1", "net.local.stream.sendspace"=>"8192", "net.inet.tcp.socket_unlocked_on_output"=>"1", "net.inet.ip.fw.verbose_limit"=>"0", "net.local.dgram.recvspace"=>"4096", "net.inet.ipsec.debug"=>"0", "net.link.ether.inet.log_arp_warnings"=>"0", "net.inet.tcp.ecn_negotiate_in"=>"0", "net.inet.tcp.rfc3465"=>"1", "net.inet.tcp.icmp_may_rst"=>"1", "net.link.ether.inet.sendllconflict"=>"0", "net.inet.ipsec.ah_offsetmask"=>"0", "net.key.blockacq_count"=>"10", "net.inet.tcp.delayed_ack"=>"3", "net.inet.ip.fw.verbose"=>"2", "net.inet.ip.fw.dyn_count"=>"0", "net.inet.tcp.slowlink_wsize"=>"8192", "net.inet6.ip6.fw.enable"=>"1", "net.inet.ip.portrange.hilast"=>"65535", "net.inet.icmp.maskrepl"=>"0", "net.link.ether.inet.apple_hwcksum_rx"=>"1", "net.inet.tcp.drop_synfin"=>"1", "net.key.spi_maxval"=>"268435455", "net.inet.ipsec.ecn"=>"0", "net.inet.ip.fw.dyn_keepalive"=>"1", "net.key.int_random"=>"60", "net.key.debug"=>"0", "net.inet.ip.dummynet.curr_time"=>"0", "net.inet.udp.blackhole"=>"0", "net.athaggrqmin"=>"1 1", "net.inet.ip.fw.dyn_syn_lifetime"=>"20", "net.inet.tcp.keepidle"=>"7200000", "net.inet6.ip6.tempvltime"=>"604800", "net.inet.tcp.recvspace"=>"358400", "net.inet.udp.maxdgram"=>"9216", "net.inet.tcp.keepintvl"=>"75000", "net.inet.ip.maxchainsent"=>"0", "net.athppmenable"=>"1 1", "net.inet.ipsec.esp_net_deflev"=>"1", "net.inet6.icmp6.nd6_useloopback"=>"1", "net.inet.tcp.slowstart_flightsize"=>"1", "net.inet.ip.fw.debug"=>"0", "net.inet.ip.linklocal.in.allowbadttl"=>"1", "net.key.spi_minval"=>"256", "net.inet.ip.forwarding"=>"0", "net.inet.tcp.v6mssdflt"=>"1024", "net.key.larval_lifetime"=>"30", "net.inet6.ip6.fw.verbose_limit"=>"0", "net.inet.ip.dummynet.red_lookup_depth"=>"256", "net.inet.tcp.pcbcount"=>"36", "net.inet.ip.fw.dyn_ack_lifetime"=>"300", "net.athCCAThreshold"=>"28 28", "net.inet.ip.portrange.lowlast"=>"600", "net.link.ether.inet.useloopback"=>"1", "net.athqdepth"=>"0 0", "net.inet.ip.ttl"=>"64", "net.inet.ip.rtmaxcache"=>"128", "net.inet.ipsec.bypass"=>"0", "net.inet6.icmp6.nd6_debug"=>"0", "net.inet.ip.use_route_genid"=>"1", "net.inet6.icmp6.rediraccept"=>"1", "net.inet.ip.fw.static_count"=>"1", "net.inet6.ip6.fw.debug"=>"0", "net.inet.udp.pcbcount"=>"104", "net.inet.ipsec.esp_randpad"=>"-1", "net.inet6.icmp6.nd6_maxnudhint"=>"0", "net.inet.tcp.always_keepalive"=>"0", "net.inet.udp.checksum"=>"1", "net.link.ether.inet.keep_announcements"=>"1", "net.athfixedDropThresh"=>"150 150", "net.inet6.ip6.kame_version"=>"20010528/apple-darwin", "net.inet.ip.fw.dyn_max"=>"4096", "net.inet.udp.log_in_vain"=>"0", "net.inet6.icmp6.nd6_mmaxtries"=>"3", "net.inet.ip.rtminexpire"=>"10", "net.inet.ip.fw.dyn_buckets"=>"256", "net.inet6.ip6.accept_rtadv"=>"0", "net.inet6.ip6.rr_prune"=>"5", "net.key.ah_keymin"=>"128", "net.inet.ip.redirect"=>"1", "net.inet.tcp.sack_globalmaxholes"=>"65536", "net.inet.ip.keepfaith"=>"0", "net.inet.ip.dummynet.expire"=>"1", "net.inet.ip.gifttl"=>"30", "net.inet.ip.portrange.last"=>"65535", "net.inet.ipsec.ah_net_deflev"=>"1", "net.inet6.icmp6.nd6_delay"=>"5", "net.inet.tcp.packetchain"=>"50", "net.inet6.ip6.hdrnestlimit"=>"50", "net.inet.tcp.newreno"=>"0", "net.inet6.ip6.dad_count"=>"1", "net.inet6.ip6.auto_linklocal"=>"1", "net.inet6.ip6.temppltime"=>"86400", "net.inet.tcp.strict_rfc1948"=>"0", "net.inet.ip.dummynet.red_max_pkt_size"=>"1500", "net.inet.ip.maxfrags"=>"2048", "net.inet.tcp.log_in_vain"=>"0", "net.athdupie"=>"1 1", "net.inet.tcp.rfc1323"=>"1", "net.inet.ip.subnets_are_local"=>"0", "net.inet.ip.dummynet.search_steps"=>"0", "net.inet.icmp.icmplim"=>"250", "net.link.ether.inet.apple_hwcksum_tx"=>"1", "net.inet6.icmp6.redirtimeout"=>"600", "net.inet.ipsec.ah_cleartos"=>"1", "net.inet6.ip6.log_interval"=>"5", "net.link.ether.inet.max_age"=>"1200", "net.inet.ip.fw.enable"=>"1", "net.inet6.ip6.redirect"=>"1", "net.athaggrfmax"=>"28 28", "net.inet.ip.maxfragsperpacket"=>"128", "net.inet6.ip6.use_deprecated"=>"1", "net.link.generic.system.dlil_input_sanity_check"=>"0", "net.inet.tcp.sack_globalholes"=>"0", "net.inet.tcp.reass.cursegments"=>"0", "net.inet6.icmp6.nodeinfo"=>"3", "net.local.inflight"=>"0", "net.inet.ip.dummynet.hash_size"=>"64", "net.inet.ip.dummynet.red_avg_pkt_size"=>"512", "net.inet.ipsec.dfbit"=>"0", "net.inet.tcp.reass.overflows"=>"0", "net.inet.tcp.rexmt_thresh"=>"2", "net.inet6.ip6.maxfrags"=>"8192", "net.inet6.ip6.rtminexpire"=>"10", "net.inet6.ipsec6.esp_net_deflev"=>"1", "net.inet.tcp.blackhole"=>"0", "net.key.esp_keymin"=>"256", "net.inet.ip.check_interface"=>"0", "net.inet.tcp.minmssoverload"=>"0", "net.link.ether.inet.maxtries"=>"5", "net.inet.tcp.do_tcpdrain"=>"0", "net.inet.ipsec.esp_port"=>"4500", "net.inet6.ipsec6.ah_net_deflev"=>"1", "net.inet.ip.dummynet.extract_heap"=>"0", "net.inet.tcp.path_mtu_discovery"=>"1", "net.inet.ip.intr_queue_maxlen"=>"50", "net.inet.ipsec.def_policy"=>"1", "net.inet.ip.fw.autoinc_step"=>"100", "net.inet.ip.accept_sourceroute"=>"0", "net.inet.raw.maxdgram"=>"8192", "net.inet.ip.maxfragpackets"=>"1024", "net.inet.ip.fw.one_pass"=>"0", "net.appletalk.routermix"=>"2000", "net.inet.tcp.tcp_lq_overflow"=>"1", "net.link.generic.system.ifcount"=>"9", "net.link.ether.inet.send_conflicting_probes"=>"1", "net.inet.tcp.background_io_enabled"=>"1", "net.inet6.ipsec6.debug"=>"0", "net.inet.tcp.win_scale_factor"=>"3", "net.key.natt_keepalive_interval"=>"20", "net.inet.tcp.msl"=>"15000", "net.inet.ip.portrange.hifirst"=>"49152", "net.inet.ipsec.ah_trans_deflev"=>"1", "net.inet.tcp.rtt_min"=>"1", "net.inet6.ip6.defmcasthlim"=>"1", "net.inet6.icmp6.nd6_prune"=>"1", "net.inet6.ip6.fw.verbose"=>"0", "net.inet.ip.portrange.lowfirst"=>"1023", "net.inet.tcp.maxseg_unacked"=>"8", "net.local.dgram.maxdgram"=>"2048", "net.key.blockacq_lifetime"=>"20", "net.inet.tcp.sack_maxholes"=>"128", "net.inet6.ip6.maxfragpackets"=>"1024", "net.inet6.ip6.use_tempaddr"=>"0", "net.athpowermode"=>"0 0", "net.inet.udp.recvspace"=>"73728", "net.inet.tcp.isn_reseed_interval"=>"0", "net.inet.tcp.local_slowstart_flightsize"=>"8", "net.inet.ip.dummynet.searches"=>"0", "net.inet.ip.intr_queue_drops"=>"0", "net.link.generic.system.multi_threaded_input"=>"1", "net.inet.raw.recvspace"=>"8192", "net.inet.ipsec.esp_trans_deflev"=>"1", "net.key.prefered_oldsa"=>"0", "net.local.stream.recvspace"=>"8192", "net.inet.tcp.sockthreshold"=>"64", "net.inet6.icmp6.nd6_umaxtries"=>"3", "net.pstimeout"=>"20 20", "net.inet.ip.sourceroute"=>"0", "net.inet.ip.fw.dyn_short_lifetime"=>"5", "net.inet.tcp.minmss"=>"216", "net.inet6.ip6.gifhlim"=>"0", "net.athvendorie"=>"1 1", "net.inet.ip.check_route_selfref"=>"1", "net.inet.icmp.log_redirect"=>"0", "net.inet6.icmp6.errppslimit"=>"100", "net.inet.tcp.mssdflt"=>"512", "net.inet.icmp.drop_redirect"=>"0", "net.inet6.ipsec6.esp_randpad"=>"-1", "net.inet6.ipsec6.ah_trans_deflev"=>"1", "net.inet.ip.random_id"=>"1", "net.inet.icmp.timestamp"=>"0"}, "interfaces"=>{"stf0"=>{"flags"=>[], "number"=>"0", "mtu"=>"1280", "type"=>"stf", "encapsulation"=>"6to4"}, "vmnet1"=>{"flags"=>["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], "number"=>"1", "addresses"=>[{"broadcast"=>"192.168.88.255", "netmask"=>"255.255.255.0", "family"=>"inet", "address"=>"192.168.88.1"}, {"family"=>"lladdr", "address"=>"private"}], "mtu"=>"1500", "type"=>"vmnet", "encapsulation"=>"Ethernet"}, "vboxnet0"=>{"flags"=>["BROADCAST", "RUNNING", "SIMPLEX", "MULTICAST"], "number"=>"0", "addresses"=>[{"family"=>"lladdr", "address"=>"private"}], "mtu"=>"1500", "type"=>"vboxnet", "encapsulation"=>"Ethernet"}, "lo0"=>{"flags"=>["UP", "LOOPBACK", "RUNNING", "MULTICAST"], "number"=>"0", "addresses"=>[{"scope"=>"Link", "prefixlen"=>"64", "family"=>"inet6", "address"=>"fe80::1"}, {"netmask"=>"255.0.0.0", "family"=>"inet", "address"=>"127.0.0.1"}, {"scope"=>"Node", "prefixlen"=>"128", "family"=>"inet6", "address"=>"::1"}, {"scope"=>"Node", "prefixlen"=>"128", "family"=>"inet6", "address"=>"private"}], "mtu"=>"16384", "type"=>"lo", "encapsulation"=>"Loopback"}, "vboxn"=>{"counters"=>{"tx"=>{"packets"=>"0", "bytes"=>"0", "compressed"=>0, "collisions"=>"0", "carrier"=>0, "errors"=>"0", "drop"=>0, "overrun"=>0}, "rx"=>{"packets"=>"0", "bytes"=>"0", "compressed"=>0, "errors"=>"0", "drop"=>0, "overrun"=>0, "multicast"=>0, "frame"=>0}}}, "gif0"=>{"flags"=>["POINTOPOINT", "MULTICAST"], "number"=>"0", "mtu"=>"1280", "type"=>"gif", "encapsulation"=>"IPIP"}, "vmnet"=>{"counters"=>{"tx"=>{"packets"=>"0", "bytes"=>"0", "compressed"=>0, "collisions"=>"0", "carrier"=>0, "errors"=>"0", "drop"=>0, "overrun"=>0}, "rx"=>{"packets"=>"0", "bytes"=>"0", "compressed"=>0, "errors"=>"0", "drop"=>0, "overrun"=>0, "multicast"=>0, "frame"=>0}}}, "en0"=>{"flags"=>["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], "status"=>"inactive", "number"=>"0", "addresses"=>[{"family"=>"lladdr", "address"=>"private"}], "mtu"=>"1500", "type"=>"en", "media"=>{"supported"=>[{"autoselect"=>{"options"=>[]}}, {"10baseT/UTP"=>{"options"=>["half-duplex"]}}, {"10baseT/UTP"=>{"options"=>["full-duplex"]}}, {"10baseT/UTP"=>{"options"=>["full-duplex", "hw-loopback"]}}, {"10baseT/UTP"=>{"options"=>["full-duplex", "flow-control"]}}, {"100baseTX"=>{"options"=>["half-duplex"]}}, {"100baseTX"=>{"options"=>["full-duplex"]}}, {"100baseTX"=>{"options"=>["full-duplex", "hw-loopback"]}}, {"100baseTX"=>{"options"=>["full-duplex", "flow-control"]}}, {"1000baseT"=>{"options"=>["full-duplex"]}}, {"1000baseT"=>{"options"=>["full-duplex", "hw-loopback"]}}, {"1000baseT"=>{"options"=>["full-duplex", "flow-control"]}}, {"none"=>{"options"=>[]}}], "selected"=>[{"autoselect"=>{"options"=>[]}}]}, "counters"=>{"tx"=>{"packets"=>"0", "bytes"=>"342", "compressed"=>0, "collisions"=>"0", "carrier"=>0, "errors"=>"0", "drop"=>0, "overrun"=>0}, "rx"=>{"packets"=>"0", "bytes"=>"0", "compressed"=>0, "errors"=>"0", "drop"=>0, "overrun"=>0, "multicast"=>0, "frame"=>0}}, "encapsulation"=>"Ethernet"}, "vmnet8"=>{"flags"=>["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], "number"=>"8", "addresses"=>[{"broadcast"=>"192.168.237.255", "netmask"=>"255.255.255.0", "family"=>"inet", "address"=>"192.168.237.1"}, {"family"=>"lladdr", "address"=>"private"}], "mtu"=>"1500", "type"=>"vmnet", "encapsulation"=>"Ethernet"}, "en1"=>{"flags"=>["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], "status"=>"active", "number"=>"1", "addresses"=>[{"scope"=>"Link", "prefixlen"=>"64", "family"=>"inet6", "address"=>"private"}, {"broadcast"=>"192.168.1.255", "netmask"=>"255.255.255.0", "family"=>"inet", "address"=>"192.168.1.4"}, {"family"=>"lladdr", "address"=>"private"}], "mtu"=>"1500", "type"=>"en", "media"=>{"supported"=>[{"autoselect"=>{"options"=>[]}}], "selected"=>[{"autoselect"=>{"options"=>[]}}]}, "counters"=>{"tx"=>{"packets"=>"7041789", "bytes"=>"449206298", "compressed"=>0, "collisions"=>"0", "carrier"=>0, "errors"=>"95", "drop"=>0, "overrun"=>0}, "rx"=>{"packets"=>"19966002", "bytes"=>"13673879120", "compressed"=>0, "errors"=>"1655893", "drop"=>0, "overrun"=>0, "multicast"=>0, "frame"=>0}}, "encapsulation"=>"Ethernet", "arp"=>{"192.168.1.7"=>"private"}}, "fw0"=>{"flags"=>["UP", "BROADCAST", "SMART", "RUNNING", "SIMPLEX", "MULTICAST"], "status"=>"inactive", "number"=>"0", "addresses"=>[{"family"=>"lladdr", "address"=>"private"}], "mtu"=>"4078", "type"=>"fw", "media"=>{"supported"=>[{"autoselect"=>{"options"=>["full-duplex"]}}], "selected"=>[{"autoselect"=>{"options"=>["full-duplex"]}}]}, "counters"=>{"tx"=>{"packets"=>"0", "bytes"=>"346", "compressed"=>0, "collisions"=>"0", "carrier"=>0, "errors"=>"0", "drop"=>0, "overrun"=>0}, "rx"=>{"packets"=>"0", "bytes"=>"0", "compressed"=>0, "errors"=>"0", "drop"=>0, "overrun"=>0, "multicast"=>0, "frame"=>0}}, "encapsulation"=>"1394"}}}, "os"=>"darwin", "domain"=>"local", "ohai_time"=>1240624355.08575, "platform_build"=>"9G55", "os_version"=>"9.6.0", "hostname"=>"local", "languages"=>{"ruby"=>{"target_os"=>"darwin9.0", "platform"=>"universal-darwin9.0", "host_vendor"=>"apple", "target_cpu"=>"i686", "target_vendor"=>"apple", "host_os"=>"darwin9.0", "version"=>"1.8.6", "host_cpu"=>"i686", "host"=>"i686-apple-darwin9.0", "release_date"=>"2008-03-03", "target"=>"i686-apple-darwin9.0"}}, "macaddress"=>"private"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# CODING: UTF-8
|
|
3
|
+
|
|
4
|
+
require 'rbconfig'
|
|
5
|
+
RUBY_PATH=File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
|
6
|
+
RAKE_PATH=File.join(Config::CONFIG['bindir'], 'rake')
|
|
7
|
+
require 'bullshit'
|
|
8
|
+
case ARGV.first
|
|
9
|
+
when 'ext'
|
|
10
|
+
require 'json/ext'
|
|
11
|
+
when 'pure'
|
|
12
|
+
require 'json/pure'
|
|
13
|
+
when 'yaml'
|
|
14
|
+
require 'yaml'
|
|
15
|
+
require 'json/pure'
|
|
16
|
+
when 'rails'
|
|
17
|
+
require 'active_support'
|
|
18
|
+
require 'json/pure'
|
|
19
|
+
when 'yajl'
|
|
20
|
+
require 'yajl'
|
|
21
|
+
require 'json/pure'
|
|
22
|
+
else
|
|
23
|
+
require 'json/pure'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
module Parser2BenchmarkCommon
|
|
27
|
+
include JSON
|
|
28
|
+
|
|
29
|
+
def setup
|
|
30
|
+
@big = @json = File.read(File.join(File.dirname(__FILE__), 'ohai.json'))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def generic_reset_method
|
|
34
|
+
@result == @big or raise "not equal"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
class Parser2BenchmarkExt < Bullshit::RepeatCase
|
|
39
|
+
include Parser2BenchmarkCommon
|
|
40
|
+
|
|
41
|
+
warmup yes
|
|
42
|
+
iterations 2000
|
|
43
|
+
|
|
44
|
+
truncate_data do
|
|
45
|
+
enabled false
|
|
46
|
+
alpha_level 0.05
|
|
47
|
+
window_size 50
|
|
48
|
+
slope_angle 0.1
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
autocorrelation do
|
|
52
|
+
alpha_level 0.05
|
|
53
|
+
max_lags 50
|
|
54
|
+
file yes
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
|
58
|
+
output_filename benchmark_name + '.log'
|
|
59
|
+
data_file yes
|
|
60
|
+
histogram yes
|
|
61
|
+
|
|
62
|
+
def benchmark_parser
|
|
63
|
+
@result = JSON.parse(@json)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
alias reset_parser generic_reset_method
|
|
67
|
+
|
|
68
|
+
def benchmark_parser_symbolic
|
|
69
|
+
@result = JSON.parse(@json, :symbolize_names => true)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
alias reset_parser_symbolc generic_reset_method
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
class Parser2BenchmarkPure < Bullshit::RepeatCase
|
|
76
|
+
include Parser2BenchmarkCommon
|
|
77
|
+
|
|
78
|
+
warmup yes
|
|
79
|
+
iterations 400
|
|
80
|
+
|
|
81
|
+
truncate_data do
|
|
82
|
+
enabled false
|
|
83
|
+
alpha_level 0.05
|
|
84
|
+
window_size 50
|
|
85
|
+
slope_angle 0.1
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
autocorrelation do
|
|
89
|
+
alpha_level 0.05
|
|
90
|
+
max_lags 50
|
|
91
|
+
file yes
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
|
95
|
+
output_filename benchmark_name + '.log'
|
|
96
|
+
data_file yes
|
|
97
|
+
histogram yes
|
|
98
|
+
|
|
99
|
+
def benchmark_parser
|
|
100
|
+
@result = JSON.parse(@json)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
alias reset_parser generic_reset_method
|
|
104
|
+
|
|
105
|
+
def benchmark_parser_symbolic
|
|
106
|
+
@result = JSON.parse(@json, :symbolize_names => true)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
alias reset_parser_symbolc generic_reset_method
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
class Parser2BenchmarkYAML < Bullshit::RepeatCase
|
|
113
|
+
warmup yes
|
|
114
|
+
iterations 400
|
|
115
|
+
|
|
116
|
+
truncate_data do
|
|
117
|
+
enabled false
|
|
118
|
+
alpha_level 0.05
|
|
119
|
+
window_size 50
|
|
120
|
+
slope_angle 0.1
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
autocorrelation do
|
|
124
|
+
alpha_level 0.05
|
|
125
|
+
max_lags 50
|
|
126
|
+
file yes
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
|
130
|
+
output_filename benchmark_name + '.log'
|
|
131
|
+
data_file yes
|
|
132
|
+
histogram yes
|
|
133
|
+
|
|
134
|
+
def setup
|
|
135
|
+
@big = @json = File.read(File.join(File.dirname(__FILE__), 'ohai.json'))
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def benchmark_parser
|
|
139
|
+
@result = YAML.load(@json)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def generic_reset_method
|
|
143
|
+
@result == @big or raise "not equal"
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
class Parser2BenchmarkRails < Bullshit::RepeatCase
|
|
148
|
+
warmup yes
|
|
149
|
+
iterations 400
|
|
150
|
+
|
|
151
|
+
truncate_data do
|
|
152
|
+
alpha_level 0.05
|
|
153
|
+
window_size 50
|
|
154
|
+
slope_angle 0.1
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
autocorrelation do
|
|
158
|
+
alpha_level 0.05
|
|
159
|
+
max_lags 50
|
|
160
|
+
file yes
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
|
164
|
+
output_filename benchmark_name + '.log'
|
|
165
|
+
data_file yes
|
|
166
|
+
histogram yes
|
|
167
|
+
|
|
168
|
+
def setup
|
|
169
|
+
a = [ nil, false, true, "fÖß\nÄr", [ "n€st€d", true ], { "fooß" => "bär", "qu\r\nux" => true } ]
|
|
170
|
+
@big = a * 100
|
|
171
|
+
@json = JSON.generate(@big)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def benchmark_parser
|
|
175
|
+
@result = ActiveSupport::JSON.decode(@json)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
def generic_reset_method
|
|
179
|
+
@result == @big or raise "not equal"
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
class Parser2BenchmarkYajl < Bullshit::RepeatCase
|
|
184
|
+
warmup yes
|
|
185
|
+
iterations 2000
|
|
186
|
+
|
|
187
|
+
truncate_data do
|
|
188
|
+
alpha_level 0.05
|
|
189
|
+
window_size 50
|
|
190
|
+
slope_angle 0.1
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
autocorrelation do
|
|
194
|
+
alpha_level 0.05
|
|
195
|
+
max_lags 50
|
|
196
|
+
file yes
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
|
200
|
+
output_filename benchmark_name + '.log'
|
|
201
|
+
data_file yes
|
|
202
|
+
histogram yes
|
|
203
|
+
|
|
204
|
+
def setup
|
|
205
|
+
@big = @json = File.read(File.join(File.dirname(__FILE__), 'ohai.json'))
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def benchmark_parser
|
|
209
|
+
@result = Yajl::Parser.new.parse(@json)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
def generic_reset_method
|
|
213
|
+
@result == @big or raise "not equal"
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
if $0 == __FILE__
|
|
218
|
+
Bullshit::Case.autorun false
|
|
219
|
+
|
|
220
|
+
case ARGV.first
|
|
221
|
+
when 'ext'
|
|
222
|
+
Parser2BenchmarkExt.run
|
|
223
|
+
when 'pure'
|
|
224
|
+
Parser2BenchmarkPure.run
|
|
225
|
+
when 'yaml'
|
|
226
|
+
Parser2BenchmarkYAML.run
|
|
227
|
+
when 'rails'
|
|
228
|
+
Parser2BenchmarkRails.run
|
|
229
|
+
when 'yajl'
|
|
230
|
+
Parser2BenchmarkYajl.run
|
|
231
|
+
else
|
|
232
|
+
system "#{RAKE_PATH} clean"
|
|
233
|
+
system "#{RUBY_PATH} #$0 yaml"
|
|
234
|
+
system "#{RUBY_PATH} #$0 rails"
|
|
235
|
+
system "#{RUBY_PATH} #$0 pure"
|
|
236
|
+
system "#{RAKE_PATH} compile_ext"
|
|
237
|
+
system "#{RUBY_PATH} #$0 ext"
|
|
238
|
+
system "#{RUBY_PATH} #$0 yajl"
|
|
239
|
+
Bullshit.compare do
|
|
240
|
+
output_filename File.join(File.dirname(__FILE__), 'data', 'Parser2BenchmarkComparison.log')
|
|
241
|
+
|
|
242
|
+
benchmark Parser2BenchmarkExt, :parser, :load => yes
|
|
243
|
+
benchmark Parser2BenchmarkExt, :parser_symbolic, :load => yes
|
|
244
|
+
benchmark Parser2BenchmarkPure, :parser, :load => yes
|
|
245
|
+
benchmark Parser2BenchmarkPure, :parser_symbolic, :load => yes
|
|
246
|
+
benchmark Parser2BenchmarkYAML, :parser, :load => yes
|
|
247
|
+
benchmark Parser2BenchmarkRails, :parser, :load => yes
|
|
248
|
+
benchmark Parser2BenchmarkYajl, :parser, :load => yes
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
end
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# CODING: UTF-8
|
|
3
|
+
|
|
4
|
+
require 'rbconfig'
|
|
5
|
+
RUBY_PATH=File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
|
6
|
+
RAKE_PATH=File.join(Config::CONFIG['bindir'], 'rake')
|
|
7
|
+
require 'bullshit'
|
|
8
|
+
case ARGV.first
|
|
9
|
+
when 'ext'
|
|
10
|
+
require 'json/ext'
|
|
11
|
+
when 'pure'
|
|
12
|
+
require 'json/pure'
|
|
13
|
+
when 'yaml'
|
|
14
|
+
require 'yaml'
|
|
15
|
+
require 'json/pure'
|
|
16
|
+
when 'rails'
|
|
17
|
+
require 'active_support'
|
|
18
|
+
require 'json/pure'
|
|
19
|
+
when 'yajl'
|
|
20
|
+
require 'yajl'
|
|
21
|
+
require 'json/pure'
|
|
22
|
+
else
|
|
23
|
+
require 'json/pure'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
module ParserBenchmarkCommon
|
|
27
|
+
include JSON
|
|
28
|
+
|
|
29
|
+
def setup
|
|
30
|
+
a = [ nil, false, true, "fÖß\nÄr", [ "n€st€d", true ], { "fooß" => "bär", "qu\r\nux" => true } ]
|
|
31
|
+
@big = a * 100
|
|
32
|
+
@json = JSON.generate(@big)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def generic_reset_method
|
|
36
|
+
@result == @big or raise "not equal"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
class ParserBenchmarkExt < Bullshit::RepeatCase
|
|
41
|
+
include ParserBenchmarkCommon
|
|
42
|
+
|
|
43
|
+
warmup yes
|
|
44
|
+
iterations 2000
|
|
45
|
+
|
|
46
|
+
truncate_data do
|
|
47
|
+
enabled false
|
|
48
|
+
alpha_level 0.05
|
|
49
|
+
window_size 50
|
|
50
|
+
slope_angle 0.1
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
autocorrelation do
|
|
54
|
+
alpha_level 0.05
|
|
55
|
+
max_lags 50
|
|
56
|
+
file yes
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
|
60
|
+
output_filename benchmark_name + '.log'
|
|
61
|
+
data_file yes
|
|
62
|
+
histogram yes
|
|
63
|
+
|
|
64
|
+
def benchmark_parser
|
|
65
|
+
@result = JSON.parse(@json)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
alias reset_parser generic_reset_method
|
|
69
|
+
|
|
70
|
+
def benchmark_parser_symbolic
|
|
71
|
+
@result = JSON.parse(@json, :symbolize_names => true)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
alias reset_parser_symbolc generic_reset_method
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
class ParserBenchmarkPure < Bullshit::RepeatCase
|
|
78
|
+
include ParserBenchmarkCommon
|
|
79
|
+
|
|
80
|
+
warmup yes
|
|
81
|
+
iterations 400
|
|
82
|
+
|
|
83
|
+
truncate_data do
|
|
84
|
+
enabled false
|
|
85
|
+
alpha_level 0.05
|
|
86
|
+
window_size 50
|
|
87
|
+
slope_angle 0.1
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
autocorrelation do
|
|
91
|
+
alpha_level 0.05
|
|
92
|
+
max_lags 50
|
|
93
|
+
file yes
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
|
97
|
+
output_filename benchmark_name + '.log'
|
|
98
|
+
data_file yes
|
|
99
|
+
histogram yes
|
|
100
|
+
|
|
101
|
+
def benchmark_parser
|
|
102
|
+
@result = JSON.parse(@json)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
alias reset_parser generic_reset_method
|
|
106
|
+
|
|
107
|
+
def benchmark_parser_symbolic
|
|
108
|
+
@result = JSON.parse(@json, :symbolize_names => true)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
alias reset_parser_symbolc generic_reset_method
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
class ParserBenchmarkYAML < Bullshit::RepeatCase
|
|
115
|
+
warmup yes
|
|
116
|
+
iterations 400
|
|
117
|
+
|
|
118
|
+
truncate_data do
|
|
119
|
+
enabled false
|
|
120
|
+
alpha_level 0.05
|
|
121
|
+
window_size 50
|
|
122
|
+
slope_angle 0.1
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
autocorrelation do
|
|
126
|
+
alpha_level 0.05
|
|
127
|
+
max_lags 50
|
|
128
|
+
file yes
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
|
132
|
+
output_filename benchmark_name + '.log'
|
|
133
|
+
data_file yes
|
|
134
|
+
histogram yes
|
|
135
|
+
|
|
136
|
+
def setup
|
|
137
|
+
a = [ nil, false, true, "fÖß\nÄr", [ "n€st€d", true ], { "fooß" => "bär", "qu\r\nux" => true } ]
|
|
138
|
+
@big = a * 100
|
|
139
|
+
@json = JSON.pretty_generate(@big)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
def benchmark_parser
|
|
143
|
+
@result = YAML.load(@json)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
def generic_reset_method
|
|
147
|
+
@result == @big or raise "not equal"
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
class ParserBenchmarkRails < Bullshit::RepeatCase
|
|
152
|
+
warmup yes
|
|
153
|
+
iterations 400
|
|
154
|
+
|
|
155
|
+
truncate_data do
|
|
156
|
+
enabled false
|
|
157
|
+
alpha_level 0.05
|
|
158
|
+
window_size 50
|
|
159
|
+
slope_angle 0.1
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
autocorrelation do
|
|
163
|
+
alpha_level 0.05
|
|
164
|
+
max_lags 50
|
|
165
|
+
file yes
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
|
169
|
+
output_filename benchmark_name + '.log'
|
|
170
|
+
data_file yes
|
|
171
|
+
histogram yes
|
|
172
|
+
|
|
173
|
+
def setup
|
|
174
|
+
a = [ nil, false, true, "fÖß\nÄr", [ "n€st€d", true ], { "fooß" => "bär", "qu\r\nux" => true } ]
|
|
175
|
+
@big = a * 100
|
|
176
|
+
@json = JSON.generate(@big)
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
def benchmark_parser
|
|
180
|
+
@result = ActiveSupport::JSON.decode(@json)
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def generic_reset_method
|
|
184
|
+
@result == @big or raise "not equal"
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
class ParserBenchmarkYajl < Bullshit::RepeatCase
|
|
189
|
+
warmup yes
|
|
190
|
+
iterations 2000
|
|
191
|
+
|
|
192
|
+
truncate_data do
|
|
193
|
+
enabled false
|
|
194
|
+
alpha_level 0.05
|
|
195
|
+
window_size 50
|
|
196
|
+
slope_angle 0.1
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
autocorrelation do
|
|
200
|
+
alpha_level 0.05
|
|
201
|
+
max_lags 50
|
|
202
|
+
file yes
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
output_dir File.join(File.dirname(__FILE__), 'data')
|
|
206
|
+
output_filename benchmark_name + '.log'
|
|
207
|
+
data_file yes
|
|
208
|
+
histogram yes
|
|
209
|
+
|
|
210
|
+
def setup
|
|
211
|
+
a = [ nil, false, true, "fÖß\nÄr", [ "n€st€d", true ], { "fooß" => "bär", "qu\r\nux" => true } ]
|
|
212
|
+
@big = a * 100
|
|
213
|
+
@json = JSON.generate(@big)
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
def benchmark_parser
|
|
217
|
+
@result = Yajl::Parser.new.parse(@json)
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
def generic_reset_method
|
|
221
|
+
@result == @big or raise "not equal"
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
if $0 == __FILE__
|
|
226
|
+
Bullshit::Case.autorun false
|
|
227
|
+
|
|
228
|
+
case ARGV.first
|
|
229
|
+
when 'ext'
|
|
230
|
+
ParserBenchmarkExt.run
|
|
231
|
+
when 'pure'
|
|
232
|
+
ParserBenchmarkPure.run
|
|
233
|
+
when 'yaml'
|
|
234
|
+
ParserBenchmarkYAML.run
|
|
235
|
+
when 'rails'
|
|
236
|
+
ParserBenchmarkRails.run
|
|
237
|
+
when 'yajl'
|
|
238
|
+
ParserBenchmarkYajl.run
|
|
239
|
+
else
|
|
240
|
+
system "#{RAKE_PATH} clean"
|
|
241
|
+
system "#{RUBY_PATH} #$0 yaml"
|
|
242
|
+
system "#{RUBY_PATH} #$0 rails"
|
|
243
|
+
system "#{RUBY_PATH} #$0 pure"
|
|
244
|
+
system "#{RAKE_PATH} compile_ext"
|
|
245
|
+
system "#{RUBY_PATH} #$0 ext"
|
|
246
|
+
system "#{RUBY_PATH} #$0 yajl"
|
|
247
|
+
Bullshit.compare do
|
|
248
|
+
output_filename File.join(File.dirname(__FILE__), 'data', 'ParserBenchmarkComparison.log')
|
|
249
|
+
|
|
250
|
+
benchmark ParserBenchmarkExt, :parser, :load => yes
|
|
251
|
+
benchmark ParserBenchmarkExt, :parser_symbolic, :load => yes
|
|
252
|
+
benchmark ParserBenchmarkPure, :parser, :load => yes
|
|
253
|
+
benchmark ParserBenchmarkPure, :parser_symbolic, :load => yes
|
|
254
|
+
benchmark ParserBenchmarkYAML, :parser, :load => yes
|
|
255
|
+
benchmark ParserBenchmarkRails, :parser, :load => yes
|
|
256
|
+
benchmark ParserBenchmarkYajl, :parser, :load => yes
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
end
|
data/bin/edit_json.rb
CHANGED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
require 'fileutils'
|
|
5
|
+
include FileUtils
|
|
6
|
+
|
|
7
|
+
# Parses the argument array _args_, according to the pattern _s_, to
|
|
8
|
+
# retrieve the single character command line options from it. If _s_ is
|
|
9
|
+
# 'xy:' an option '-x' without an option argument is searched, and an
|
|
10
|
+
# option '-y foo' with an option argument ('foo').
|
|
11
|
+
#
|
|
12
|
+
# An option hash is returned with all found options set to true or the
|
|
13
|
+
# found option argument.
|
|
14
|
+
def go(s, args = ARGV)
|
|
15
|
+
b, v = s.scan(/(.)(:?)/).inject([{},{}]) { |t,(o,a)|
|
|
16
|
+
t[a.empty? ? 0 : 1][o] = a.empty? ? false : nil
|
|
17
|
+
t
|
|
18
|
+
}
|
|
19
|
+
while a = args.shift
|
|
20
|
+
a !~ /\A-(.+)/ and args.unshift a and break
|
|
21
|
+
p = $1
|
|
22
|
+
until p == ''
|
|
23
|
+
o = p.slice!(0, 1)
|
|
24
|
+
if v.key?(o)
|
|
25
|
+
v[o] = if p == '' then args.shift or break 1 else p end
|
|
26
|
+
break
|
|
27
|
+
elsif b.key?(o)
|
|
28
|
+
b[o] = true
|
|
29
|
+
else
|
|
30
|
+
args.unshift a
|
|
31
|
+
break 1
|
|
32
|
+
end
|
|
33
|
+
end and break
|
|
34
|
+
end
|
|
35
|
+
b.merge(v)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
opts = go 'slhi:', args = ARGV.dup
|
|
39
|
+
if opts['h'] || opts['l'] && opts['s']
|
|
40
|
+
puts <<EOT
|
|
41
|
+
Usage: #{File.basename($0)} [OPTION] [FILE]
|
|
42
|
+
|
|
43
|
+
If FILE is skipped, this scripts waits for input from STDIN. Otherwise
|
|
44
|
+
FILE is opened, read, and used as input for the prettifier.
|
|
45
|
+
|
|
46
|
+
OPTION can be
|
|
47
|
+
-s to output the shortest possible JSON (precludes -l)
|
|
48
|
+
-l to output a longer, better formatted JSON (precludes -s)
|
|
49
|
+
-i EXT prettifies FILE in place, saving a backup to FILE.EXT
|
|
50
|
+
-h this help
|
|
51
|
+
EOT
|
|
52
|
+
exit 0
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
filename = nil
|
|
56
|
+
json = JSON[
|
|
57
|
+
if args.empty?
|
|
58
|
+
STDIN.read
|
|
59
|
+
else
|
|
60
|
+
File.read filename = args.first
|
|
61
|
+
end
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
output = if opts['s']
|
|
65
|
+
JSON.fast_generate json
|
|
66
|
+
else # default is -l
|
|
67
|
+
JSON.pretty_generate json
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
if opts['i'] && filename
|
|
71
|
+
cp filename, "#{filename}.#{opts['i']}"
|
|
72
|
+
File.open(filename, 'w') { |f| f.puts output }
|
|
73
|
+
else
|
|
74
|
+
puts output
|
|
75
|
+
end
|