jrjackson 0.2.9 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/{.jrubyrc → .__jrubyrc} +2 -2
  3. data/.gitignore +5 -0
  4. data/Gemfile +1 -0
  5. data/alt_bench.rb +46 -0
  6. data/dependency-reduced-pom.xml +6 -5
  7. data/lib/jrjackson/build_info.rb +2 -2
  8. data/lib/jrjackson/jars/jrjackson-1.2.16.jar +0 -0
  9. data/lib/jrjackson/jrjackson.rb +38 -13
  10. data/pom.xml +11 -10
  11. data/run_all_individual_bench.sh +17 -15
  12. data/run_jruby_individual_bench.sh +20 -0
  13. data/run_mri_individual_bench.sh +7 -0
  14. data/src/main/java/com/jrjackson/IParseHandler.java +53 -0
  15. data/src/main/java/com/jrjackson/JavaBigDecimalValueConverter.java +17 -0
  16. data/src/main/java/com/jrjackson/JavaBigIntValueConverter.java +17 -0
  17. data/src/main/java/com/jrjackson/JavaConverter.java +10 -0
  18. data/src/main/java/com/jrjackson/JavaFloatValueConverter.java +16 -0
  19. data/src/main/java/com/jrjackson/JavaHandler.java +118 -0
  20. data/src/main/java/com/jrjackson/JavaLongValueConverter.java +16 -0
  21. data/src/main/java/com/jrjackson/JjParse.java +147 -0
  22. data/src/main/java/com/jrjackson/JrJacksonBase.java +159 -0
  23. data/src/main/java/com/jrjackson/JrJacksonJava.java +81 -0
  24. data/src/main/java/com/jrjackson/JrJacksonRaw.java +59 -102
  25. data/src/main/java/com/jrjackson/JrJacksonRuby.java +117 -0
  26. data/src/main/java/com/jrjackson/JrJacksonSaj.java +26 -0
  27. data/src/main/java/com/jrjackson/JrJacksonSch.java +25 -0
  28. data/src/main/java/com/jrjackson/JrJacksonService.java +15 -0
  29. data/src/main/java/com/jrjackson/JrParse.java +149 -0
  30. data/src/main/java/com/jrjackson/RubyAnySerializer.java +112 -55
  31. data/src/main/java/com/jrjackson/RubyBigDecimalValueConverter.java +18 -0
  32. data/src/main/java/com/jrjackson/RubyBigIntValueConverter.java +21 -0
  33. data/src/main/java/com/jrjackson/RubyConverter.java +12 -0
  34. data/src/main/java/com/jrjackson/RubyDateFormat.java +36 -0
  35. data/src/main/java/com/jrjackson/RubyFloatValueConverter.java +18 -0
  36. data/src/main/java/com/jrjackson/RubyHandler.java +119 -0
  37. data/src/main/java/com/jrjackson/RubyIntValueConverter.java +18 -0
  38. data/src/main/java/com/jrjackson/RubyJacksonModule.java +40 -38
  39. data/src/main/java/com/jrjackson/RubyNameConverter.java +9 -0
  40. data/src/main/java/com/jrjackson/RubyObjectDeserializer.java +24 -33
  41. data/src/main/java/com/jrjackson/RubyStringConverter.java +1 -2
  42. data/src/main/java/com/jrjackson/{RubySymbolConverter.java → RubyStringKeyConverter.java} +3 -2
  43. data/src/main/java/com/jrjackson/RubyStringNameConverter.java +12 -0
  44. data/src/main/java/com/jrjackson/RubySymbolKeyConverter.java +15 -0
  45. data/src/main/java/com/jrjackson/RubySymbolNameConverter.java +12 -0
  46. data/src/main/java/com/jrjackson/RubyUtils.java +40 -1
  47. data/src/main/java/com/jrjackson/SajParse.java +169 -0
  48. data/src/main/java/com/jrjackson/SchParse.java +209 -0
  49. data/src/main/java/com/jrjackson/StreamParse.java +66 -0
  50. data/test/jrjackson_test.rb +271 -6
  51. metadata +49 -17
  52. data/src/test/java/com/jrjackson/jruby/AppTest.java +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0da8217b380c2b90375f404bd62e1bd1fd9cfac
4
- data.tar.gz: bef6c6e1bd90a0c8eb5159b3499774f46b08923d
3
+ metadata.gz: d76ab526dd60541c4313866e49c60aaa09036e03
4
+ data.tar.gz: 293357a8f993f8ee4202dcce7d92adfd74a39d42
5
5
  SHA512:
6
- metadata.gz: 393220a4be40ca38b4147fb62d5e618c423b99ca859895b3da08e671482224dc9f4b9946f58d6ddc2c26699b681398e3c082950c37c8d0391996c8e3c3da3735
7
- data.tar.gz: d0020e8cfe4fa216c2bf4015f607123ff119d07df45d44057e362a66c57a158818a07a262c90820e3dbde4de0d8d8a52d868b1434b4bb547a4850368ba9b28e2
6
+ metadata.gz: c88d63e3cdc580c3b5a59f9c804b1ac704763c11b3debe3d7c1ccc42ae4bbe955d66e020c58132c0cb4a2b4beb24dd6a2c66301f1a9e958c8c015c51ad5f6b99
7
+ data.tar.gz: 048be75d64d16872d573c54d9eb3d6dc7eb2047fbcc817c8e40ae0973796645f06f2f9c504d7846719f4fc3380dedd27b18ae543e4551ee9a4858e2bf4c32ed6
@@ -75,7 +75,7 @@ invokedynamic.log.constants=false
75
75
 
76
76
  # Enable all possible uses of invokedynamic.
77
77
  # Options: [true, false], Default: false.
78
- invokedynamic.all=false
78
+ invokedynamic.all=true
79
79
 
80
80
  # Enable all safe (but maybe not fast) uses of invokedynamic.
81
81
  # Options: [true, false], Default: false.
@@ -259,7 +259,7 @@ jit.max=16384
259
259
 
260
260
  # Specify the major Ruby version to be compatible with.
261
261
  # Options: [1.8, 1.9, 2.0], Default: 1.9.
262
- compat.version=1.9
262
+ compat.version=2.0
263
263
 
264
264
  # Enable or disable ObjectSpace.each_object.
265
265
  # Options: [true, false], Default: false.
data/.gitignore CHANGED
@@ -2,3 +2,8 @@ Gemfile.lock
2
2
  pkg
3
3
  target
4
4
  Rakefile.old
5
+ .idea
6
+ *.iml
7
+
8
+ linked
9
+ /libyjpagent.so
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ source "https://rubygems.org"
4
4
  group :development do
5
5
  gem 'gson', '>= 0.6'
6
6
  gem 'json', '~> 1.8'
7
+ gem 'benchmark-ips'
7
8
  end
8
9
 
9
10
  gemspec
data/alt_bench.rb ADDED
@@ -0,0 +1,46 @@
1
+ # coding: utf-8
2
+ require 'benchmark/ips'
3
+ require 'json'
4
+ require File.expand_path('lib/jrjackson')
5
+
6
+ obj = {
7
+ :name => "Fredrick Smith",
8
+ :quantity => 1_000_000,
9
+ :addresses => {
10
+ :address1 => "12 Heather Street, Parnell, Auckland, New Zealand",
11
+ :address2 => "1 Queen Street, CBD, Auckland, New Zealand"
12
+ }
13
+ }
14
+
15
+ json = JSON.dump(obj)
16
+
17
+ puts "Decode ====================="
18
+
19
+ puts 'Sleeping'
20
+ sleep 45
21
+ puts 'Working'
22
+
23
+ # -JXrunhprof:cpu=samples,depth=30,file=jrjackson.hprof
24
+
25
+ Benchmark.ips do |x|
26
+ x.config(time: 20, warmup: 20)
27
+
28
+ x.report("JrJackson new Ruby") { JrJackson::Ruby.parse(json, nil) }
29
+ # x.report("JrJackson Raw") { JrJackson::Java.parse(json, nil) }
30
+ # x.report("JSON") { JSON.load(json) }
31
+
32
+ # x.report("JrJackson") { JrJackson::Raw.parse_sym(json) }
33
+
34
+ # x.compare!
35
+ end
36
+
37
+ # puts "Encode ====================="
38
+ # Benchmark.ips do |x|
39
+ # x.config(time: 5, warmup: 10)
40
+
41
+ # x.report("JrJackson Raw") { JrJackson::Base.generate(obj) }
42
+ # x.report("JrJackson") { JrJackson::Json.dump(obj) }
43
+ # x.report("JSON") { JSON.dump(obj) }
44
+
45
+ # x.compare!
46
+ # end
@@ -4,7 +4,7 @@
4
4
  <groupId>com.jrjackson.jruby</groupId>
5
5
  <artifactId>jrjackson</artifactId>
6
6
  <name>jrjackson</name>
7
- <version>1.2.12</version>
7
+ <version>1.2.16</version>
8
8
  <url>http://maven.apache.org</url>
9
9
  <build>
10
10
  <plugins>
@@ -12,11 +12,11 @@
12
12
  <artifactId>maven-compiler-plugin</artifactId>
13
13
  <version>3.1</version>
14
14
  <configuration>
15
- <source>1.6</source>
16
- <target>1.6</target>
15
+ <source>1.7</source>
16
+ <target>1.7</target>
17
17
  <showDeprecation>false</showDeprecation>
18
18
  <showWarnings>false</showWarnings>
19
- <executable>${JAVA_HOME_6}/bin/javac</executable>
19
+ <executable>${JAVA_HOME}/bin/javac</executable>
20
20
  <fork>true</fork>
21
21
  </configuration>
22
22
  </plugin>
@@ -66,7 +66,7 @@
66
66
  <dependency>
67
67
  <groupId>org.jruby</groupId>
68
68
  <artifactId>jruby</artifactId>
69
- <version>1.7.17</version>
69
+ <version>9.0.1.0</version>
70
70
  <scope>provided</scope>
71
71
  <exclusions>
72
72
  <exclusion>
@@ -81,6 +81,7 @@
81
81
  </dependency>
82
82
  </dependencies>
83
83
  <properties>
84
+ <netbeans.hint.jdkPlatform>JDK_1.8</netbeans.hint.jdkPlatform>
84
85
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
85
86
  </properties>
86
87
  </project>
@@ -1,11 +1,11 @@
1
1
  module JrJackson
2
2
  module BuildInfo
3
3
  def self.version
4
- '0.2.9'
4
+ '0.3.0'
5
5
  end
6
6
 
7
7
  def self.release_date
8
- '2015-06-24'
8
+ '2015-09-07'
9
9
  end
10
10
 
11
11
  def self.files
@@ -3,8 +3,8 @@ unless RUBY_PLATFORM =~ /java/
3
3
  exit 255
4
4
  end
5
5
 
6
- require_relative "jars/jrjackson-1.2.12.jar"
7
- # require_relative "linked/jrjackson-1.2.12.jar"
6
+ require_relative "jars/jrjackson-1.2.16.jar"
7
+ # require_relative "linked/jrjackson-1.2.16.jar"
8
8
 
9
9
  require 'com/jrjackson/jr_jackson'
10
10
 
@@ -13,28 +13,49 @@ module JrJackson
13
13
  class << self
14
14
  TIME_REGEX = %r(\A(\d{4}-\d\d-\d\d|(\w{3}\s){2}\d\d)\s\d\d:\d\d:\d\d)
15
15
 
16
- def load(json_string, options = nil)
17
- if json_string.is_a?(String) && is_time_string?(json_string)
18
- return JrJackson::Raw.parse_raw("\"#{json_string}\"")
16
+ def sj_load(handler, json_source, options = nil)
17
+ JrJackson::Saj.parse(handler, json_source, options)
18
+ end
19
+
20
+ def sc_load(handler, json_source, options = nil)
21
+ JrJackson::Sch.parse(handler, json_source, options)
22
+ end
23
+
24
+ def load_ruby(json_source, options = nil)
25
+ JrJackson::Ruby.parse(json_source, options)
26
+ end
27
+
28
+ def load_java(json_source, options = nil)
29
+ JrJackson::Java.parse(json_source, options)
30
+ end
31
+
32
+ def load(json_source, options = nil)
33
+ if json_source.is_a?(String) && is_time_string?(json_source)
34
+ return JrJackson::Raw.parse_raw("\"#{json_source}\"")
19
35
  end
20
36
 
21
37
  if options && !options.empty?
22
38
  if options.size == 1 && !!options[:raw]
23
- return JrJackson::Raw.parse_raw(json_string)
39
+ return JrJackson::Java.parse_raw(json_source, options)
24
40
  end
25
41
  if options.size == 1 && !!options[:symbolize_keys]
26
- return JrJackson::Raw.parse_sym(json_string)
42
+ return JrJackson::Ruby.parse_sym(json_source, options)
43
+ end
44
+ if options.size == 2 && !!options[:raw] && !!options[:use_bigdecimal]
45
+ return JrJackson::Java.parse(json_source, options)
27
46
  end
28
- JrJackson::Raw.parse(json_string, options)
47
+ # JrJackson::Raw.parse(json_source, options)
48
+ JrJackson::Ruby.parse(json_source, options)
29
49
  else
30
- JrJackson::Raw.parse_str(json_string)
50
+ # JrJackson::Raw.parse_str(json_source)
51
+ JrJackson::Ruby.parse(json_source, nil)
31
52
  end
32
53
  end
33
54
 
34
55
  def dump(object, options = {})
35
56
  case object
36
- when Hash, Array, String, Java::JavaUtil::Map, Java::JavaUtil::List
37
- JrJackson::Raw.generate(object, options)
57
+ when Hash, Array, String, ::Java::JavaUtil::Map, ::Java::JavaUtil::List
58
+ JrJackson::Base.generate(object, options)
38
59
  when true, false
39
60
  object.to_s
40
61
  when nil
@@ -50,13 +71,17 @@ module JrJackson
50
71
  end
51
72
  end
52
73
 
74
+ alias :sc_parse :sc_load
75
+ alias :sj_parse :sj_load
53
76
  alias :parse :load
77
+ alias :parse_ruby :load_ruby
78
+ alias :parse_java :load_java
54
79
  alias :generate :dump
55
80
 
56
81
  private
57
82
 
58
- def is_time_string?(json_string)
59
- json_string =~ TIME_REGEX
83
+ def is_time_string?(json_source)
84
+ json_source =~ TIME_REGEX
60
85
  rescue => e
61
86
  raise JrJackson::ParseError, e.message
62
87
  end
data/pom.xml CHANGED
@@ -5,12 +5,13 @@
5
5
  <groupId>com.jrjackson.jruby</groupId>
6
6
  <artifactId>jrjackson</artifactId>
7
7
  <packaging>jar</packaging>
8
- <version>1.2.12</version>
8
+ <version>1.2.16</version>
9
9
  <name>jrjackson</name>
10
10
  <url>http://maven.apache.org</url>
11
-
11
+
12
12
  <properties>
13
13
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14
+ <netbeans.hint.jdkPlatform>JDK_1.8</netbeans.hint.jdkPlatform>
14
15
  </properties>
15
16
 
16
17
  <dependencies>
@@ -23,28 +24,28 @@
23
24
  <dependency>
24
25
  <groupId>org.jruby</groupId>
25
26
  <artifactId>jruby</artifactId>
26
- <version>1.7.17</version>
27
+ <version>9.0.1.0</version>
27
28
  <scope>provided</scope>
28
29
  </dependency>
29
30
  <dependency>
30
31
  <groupId>com.fasterxml.jackson.core</groupId>
31
32
  <artifactId>jackson-core</artifactId>
32
- <version>2.4.4</version>
33
+ <version>2.6.1</version>
33
34
  </dependency>
34
35
  <dependency>
35
36
  <groupId>com.fasterxml.jackson.core</groupId>
36
37
  <artifactId>jackson-annotations</artifactId>
37
- <version>2.4.4</version>
38
+ <version>2.6.1</version>
38
39
  </dependency>
39
40
  <dependency>
40
41
  <groupId>com.fasterxml.jackson.core</groupId>
41
42
  <artifactId>jackson-databind</artifactId>
42
- <version>2.4.4</version>
43
+ <version>2.6.1</version>
43
44
  </dependency>
44
45
  <dependency>
45
46
  <groupId>com.fasterxml.jackson.module</groupId>
46
47
  <artifactId>jackson-module-afterburner</artifactId>
47
- <version>2.4.4</version>
48
+ <version>2.6.1</version>
48
49
  </dependency>
49
50
  </dependencies>
50
51
  <build>
@@ -54,11 +55,11 @@
54
55
  <artifactId>maven-compiler-plugin</artifactId>
55
56
  <version>3.1</version>
56
57
  <configuration>
57
- <source>1.6</source>
58
- <target>1.6</target>
58
+ <source>1.7</source>
59
+ <target>1.7</target>
59
60
  <showDeprecation>false</showDeprecation>
60
61
  <showWarnings>false</showWarnings>
61
- <executable>${JAVA_HOME_6}/bin/javac</executable>
62
+ <executable>${JAVA_HOME}/bin/javac</executable>
62
63
  <fork>true</fork>
63
64
  </configuration>
64
65
  </plugin>
@@ -1,23 +1,25 @@
1
1
  #!/bin/sh
2
2
 
3
- chruby-exec ruby-2.2.0 -- ruby benchmarking/individual/json-mri-sourced.rb
4
- chruby-exec ruby-2.2.0 -- ruby benchmarking/individual/oj-mri-sourced.rb
3
+ chruby-exec ruby-2.2.2 -- ruby benchmarking/individual/json-mri-sourced.rb
4
+ chruby-exec ruby-2.2.2 -- ruby benchmarking/individual/oj-mri-sourced.rb
5
5
 
6
- chruby-exec jruby-1.7.17 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/gson-jr-sourced.rb
7
- chruby-exec jruby-1.7.17 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/json-jr-sourced.rb
6
+ chruby-exec jruby-9.0.0.0.rc1 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/gson-jr-sourced.rb
7
+ chruby-exec jruby-9.0.0.0.rc1 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/json-jr-sourced.rb
8
8
 
9
- chruby-exec jruby-1.7.17 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/string-jr-sourced.rb
10
- chruby-exec jruby-1.7.17 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/str-bd-jr-sourced.rb
9
+ chruby-exec jruby-9.0.0.0.rc1 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/string-jr-sourced.rb
10
+ chruby-exec jruby-9.0.0.0.rc1 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/str-bd-jr-sourced.rb
11
11
 
12
- chruby-exec jruby-1.7.17 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/symbol-jr-sourced.rb
13
- chruby-exec jruby-1.7.17 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/sym-bd-jr-sourced.rb
12
+ chruby-exec jruby-9.0.0.0.rc1 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/symbol-jr-sourced.rb
13
+ chruby-exec jruby-9.0.0.0.rc1 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/sym-bd-jr-sourced.rb
14
14
 
15
- chruby-exec jruby-1.7.17 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/raw-jr-sourced.rb
16
- chruby-exec jruby-1.7.17 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/raw-bd-jr-sourced.rb
15
+ chruby-exec jruby-9.0.0.0.rc1 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/raw-jr-sourced.rb
16
+ chruby-exec jruby-9.0.0.0.rc1 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/raw-bd-jr-sourced.rb
17
17
 
18
- chruby-exec ruby-2.2.0 -- ruby benchmarking/individual/json-gen-mri-sourced.rb
19
- chruby-exec ruby-2.2.0 -- ruby benchmarking/individual/oj-gen-mri-sourced.rb
18
+ chruby-exec jruby-9.0.0.0.rc1 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/sj-jr-sourced.rb
20
19
 
21
- chruby-exec jruby-1.7.17 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/json-gen-jr-sourced.rb
22
- chruby-exec jruby-1.7.17 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/gson-gen-jr-sourced.rb
23
- chruby-exec jruby-1.7.17 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/raw-gen-jr-sourced.rb
20
+ chruby-exec ruby-2.2.2 -- ruby benchmarking/individual/json-gen-mri-sourced.rb
21
+ chruby-exec ruby-2.2.2 -- ruby benchmarking/individual/oj-gen-mri-sourced.rb
22
+
23
+ chruby-exec jruby-9.0.0.0.rc1 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/json-gen-jr-sourced.rb
24
+ chruby-exec jruby-9.0.0.0.rc1 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/gson-gen-jr-sourced.rb
25
+ chruby-exec jruby-9.0.0.0.rc1 -- ruby -J-Xmn512m -J-Xms2048m -J-Xmx2048m benchmarking/individual/raw-gen-jr-sourced.rb
@@ -0,0 +1,20 @@
1
+ #!/bin/sh
2
+
3
+ jruby -J-Xmn1024m -J-Xms4096m -J-Xmx4096m -S ./benchmarking/individual/json-gen-jr-sourced.rb
4
+ jruby -J-Xmn1024m -J-Xms4096m -J-Xmx4096m -S ./benchmarking/individual/gson-gen-jr-sourced.rb
5
+ jruby -J-Xmn1024m -J-Xms4096m -J-Xmx4096m -S ./benchmarking/individual/raw-gen-jr-sourced.rb
6
+
7
+ # jruby -J-Xmn1024m -J-Xms4096m -J-Xmx4096m -S ./benchmarking/individual/gson-jr-sourced.rb
8
+ jruby -J-Xmn1024m -J-Xms4096m -J-Xmx4096m -S ./benchmarking/individual/json-jr-sourced.rb
9
+
10
+ jruby -J-Xmn1024m -J-Xms4096m -J-Xmx4096m -S ./benchmarking/individual/string-jr-sourced.rb
11
+ jruby -J-Xmn1024m -J-Xms4096m -J-Xmx4096m -S ./benchmarking/individual/str-bd-jr-sourced.rb
12
+
13
+ jruby -J-Xmn1024m -J-Xms4096m -J-Xmx4096m -S ./benchmarking/individual/symbol-jr-sourced.rb
14
+ jruby -J-Xmn1024m -J-Xms4096m -J-Xmx4096m -S ./benchmarking/individual/sym-bd-jr-sourced.rb
15
+
16
+ jruby -J-Xmn1024m -J-Xms4096m -J-Xmx4096m -S ./benchmarking/individual/raw-jr-sourced.rb
17
+ jruby -J-Xmn1024m -J-Xms4096m -J-Xmx4096m -S ./benchmarking/individual/raw-bd-jr-sourced.rb
18
+
19
+ jruby -J-Xmn1024m -J-Xms4096m -J-Xmx4096m -S ./benchmarking/individual/sj-jr-sourced.rb
20
+
@@ -0,0 +1,7 @@
1
+ #!/bin/sh
2
+
3
+ ruby ./benchmarking/individual/json-mri-sourced.rb
4
+ ruby ./benchmarking/individual/oj-mri-sourced.rb
5
+
6
+ ruby ./benchmarking/individual/json-gen-mri-sourced.rb
7
+ ruby ./benchmarking/individual/oj-gen-mri-sourced.rb
@@ -0,0 +1,53 @@
1
+ /*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ package com.jrjackson;
7
+
8
+ import com.fasterxml.jackson.core.JsonParser;
9
+ import java.io.IOException;
10
+
11
+ /**
12
+ *
13
+ * @author guy
14
+ * @param <T>
15
+ * @param <U>
16
+ * @param <V>
17
+ */
18
+ public interface IParseHandler<T, U, V> {
19
+
20
+ void addValue(T value);
21
+
22
+ void arrayAppend(U array, T value);
23
+
24
+ void arrayEnd();
25
+
26
+ T arrayStart();
27
+
28
+ T falseValue();
29
+
30
+ T getResult();
31
+
32
+ void hashEnd();
33
+
34
+ T hashKey(String key);
35
+
36
+ void hashSet(V hash, T key, T value);
37
+
38
+ T hashStart();
39
+
40
+ void raiseError(String e);
41
+
42
+ T treatFloat(JsonParser jp) throws IOException;
43
+
44
+ T treatInt(JsonParser jp) throws IOException;
45
+
46
+ T treatNull();
47
+
48
+ T treatString(JsonParser jp) throws IOException;
49
+
50
+ T trueValue();
51
+
52
+
53
+ }
@@ -0,0 +1,17 @@
1
+ package com.jrjackson;
2
+
3
+ import com.fasterxml.jackson.core.JsonParser;
4
+ import java.io.IOException;
5
+ import java.math.BigDecimal;
6
+
7
+ /**
8
+ *
9
+ * @author Guy Boertje
10
+ */
11
+ public class JavaBigDecimalValueConverter implements JavaConverter {
12
+
13
+ @Override
14
+ public BigDecimal convert(JsonParser jp) throws IOException {
15
+ return jp.getDecimalValue();
16
+ }
17
+ }
@@ -0,0 +1,17 @@
1
+ package com.jrjackson;
2
+
3
+ import com.fasterxml.jackson.core.JsonParser;
4
+ import java.io.IOException;
5
+ import java.math.BigInteger;
6
+
7
+ /**
8
+ *
9
+ * @author Guy Boertje
10
+ */
11
+ public class JavaBigIntValueConverter implements JavaConverter {
12
+
13
+ @Override
14
+ public BigInteger convert(JsonParser jp) throws IOException {
15
+ return jp.getBigIntegerValue();
16
+ }
17
+ }
@@ -0,0 +1,10 @@
1
+ package com.jrjackson;
2
+
3
+ import com.fasterxml.jackson.core.*;
4
+
5
+ import java.io.IOException;
6
+
7
+ public interface JavaConverter {
8
+
9
+ public Object convert(JsonParser jp) throws IOException;
10
+ }
@@ -0,0 +1,16 @@
1
+ package com.jrjackson;
2
+
3
+ import com.fasterxml.jackson.core.JsonParser;
4
+ import java.io.IOException;
5
+
6
+ /**
7
+ *
8
+ * @author Guy Boertje
9
+ */
10
+ public class JavaFloatValueConverter implements JavaConverter {
11
+
12
+ @Override
13
+ public Double convert(JsonParser jp) throws IOException {
14
+ return jp.getDoubleValue();
15
+ }
16
+ }
@@ -0,0 +1,118 @@
1
+ package com.jrjackson;
2
+
3
+ import com.fasterxml.jackson.core.JsonParser;
4
+ import java.io.IOException;
5
+ import java.util.ArrayList;
6
+ import java.util.HashMap;
7
+
8
+
9
+ /**
10
+ *
11
+ * @author Guy Boertje
12
+ */
13
+
14
+ /*
15
+ Long -> Integer
16
+ Double -> Float
17
+ JavaMath::BigDecimal -> BigDecimal
18
+ JavaMath::BigInteger -> Bignum
19
+ JavaUtil::ArrayList -> Array
20
+ JavaUtil::LinkedHashMap -> Hash
21
+ String -> String
22
+ */
23
+
24
+ public class JavaHandler implements IParseHandler<Object, ArrayList<Object>, HashMap<String, Object>> {
25
+
26
+ private Object _result;
27
+ private final JavaConverter _intConv;
28
+ private final JavaConverter _floatConv;
29
+
30
+ public JavaHandler(
31
+ JavaConverter intConverter,
32
+ JavaConverter floatConverter) {
33
+
34
+ _intConv = intConverter;
35
+ _floatConv = floatConverter;
36
+
37
+ }
38
+
39
+ @Override
40
+ public void addValue(Object value) {
41
+ _result = value;
42
+ }
43
+
44
+ @Override
45
+ public Object hashStart() {
46
+ return new HashMap<String, Object>();
47
+ }
48
+
49
+ @Override
50
+ public void hashEnd() {
51
+
52
+ }
53
+
54
+ @Override
55
+ public Object hashKey(String key) {
56
+ return key;
57
+ }
58
+
59
+ @Override
60
+ public void hashSet(HashMap<String, Object> hash, Object key, Object value) {
61
+ hash.put((String)key, value);
62
+ }
63
+
64
+ @Override
65
+ public Object arrayStart() {
66
+ return new ArrayList<Object>();
67
+ }
68
+
69
+ @Override
70
+ public void arrayEnd() {
71
+
72
+ }
73
+
74
+ @Override
75
+ public void arrayAppend(ArrayList<Object> array, Object value) {
76
+ array.add(value);
77
+ }
78
+
79
+ @Override
80
+ public Object treatNull() {
81
+ return null;
82
+ }
83
+
84
+ @Override
85
+ public Object treatInt(JsonParser jp) throws IOException {
86
+ return _intConv.convert(jp);
87
+ }
88
+
89
+ @Override
90
+ public Object treatFloat(JsonParser jp) throws IOException {
91
+ return _floatConv.convert(jp);
92
+ }
93
+
94
+ @Override
95
+ public Object treatString(JsonParser jp) throws IOException {
96
+ return jp.getText();
97
+ }
98
+
99
+ @Override
100
+ public Object trueValue() {
101
+ return true;
102
+ }
103
+
104
+ @Override
105
+ public Object falseValue() {
106
+ return false;
107
+ }
108
+
109
+ @Override
110
+ public Object getResult() {
111
+ return _result;
112
+ }
113
+
114
+ @Override
115
+ public void raiseError(String e) {
116
+
117
+ }
118
+ }
@@ -0,0 +1,16 @@
1
+ package com.jrjackson;
2
+
3
+ import com.fasterxml.jackson.core.JsonParser;
4
+ import java.io.IOException;
5
+
6
+ /**
7
+ *
8
+ * @author Guy Boertje
9
+ */
10
+ public class JavaLongValueConverter implements JavaConverter {
11
+
12
+ @Override
13
+ public Long convert(JsonParser jp) throws IOException {
14
+ return jp.getLongValue();
15
+ }
16
+ }