fast_jsonparser 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 83a6975e89954b1817c0ba892528572b043302514270827e8555d14550495abe
4
+ data.tar.gz: f4fa65c9d8e62d9734a3eab7ec79ea28776666486cfd4b9724357093ceae935f
5
+ SHA512:
6
+ metadata.gz: 71d8922edd312b95f3d310a57e11ed6763129097b0e7780bb1c9613e203bc87d048d0bf77dcdb51245acab40990c5074326ec6fc46c649c9ce63fee5e90cb7ab
7
+ data.tar.gz: 1a36f45fe28a55aacb93d87532bcc737339ca5a21fa5c77d3cb71f8ef6db31d74d5f0edcbb37fdcd6e1babe45ec2788df852ff5001aad92bd2cc4cf7c73a4325
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.5
7
+ before_install: gem install bundler -v 2.0.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at anil@joshsoftware.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in fast_jsonparser.gemspec
4
+ gemspec
@@ -0,0 +1,29 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fast_jsonparser (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ byebug (11.1.3)
10
+ minitest (5.14.1)
11
+ oj (3.10.6)
12
+ rake (10.5.0)
13
+ rake-compiler (1.1.0)
14
+ rake
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ bundler (~> 2.0)
21
+ byebug
22
+ fast_jsonparser!
23
+ minitest (~> 5.0)
24
+ oj
25
+ rake (~> 10.0)
26
+ rake-compiler
27
+
28
+ BUNDLED WITH
29
+ 2.0.1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Anil Maurya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,331 @@
1
+
2
+ SHELL = /bin/sh
3
+
4
+ # V=0 quiet, V=1 verbose. other values don't work.
5
+ V = 0
6
+ Q1 = $(V:1=)
7
+ Q = $(Q1:0=@)
8
+ ECHO1 = $(V:1=@ :)
9
+ ECHO = $(ECHO1:0=@ echo)
10
+ NULLCMD = :
11
+
12
+ #### Start of system configuration section. ####
13
+
14
+ srcdir = ext/fast_jsonparser
15
+ topdir = /Users/anilmaurya/.rvm/rubies/ruby-2.6.5/include/ruby-2.6.0
16
+ hdrdir = $(topdir)
17
+ arch_hdrdir = /Users/anilmaurya/.rvm/rubies/ruby-2.6.5/include/ruby-2.6.0/x86_64-darwin19
18
+ PATH_SEPARATOR = :
19
+ VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
20
+
21
+ prefix = $(DESTDIR)/Users/anilmaurya/.rvm/rubies/ruby-2.6.5
22
+
23
+ rubysitearchprefix = $(rubylibprefix)/$(sitearch)
24
+
25
+ rubyarchprefix = $(rubylibprefix)/$(arch)
26
+
27
+ rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
28
+
29
+ exec_prefix = $(prefix)
30
+
31
+ vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
32
+
33
+ sitearchhdrdir = $(sitehdrdir)/$(sitearch)
34
+
35
+ rubyarchhdrdir = $(rubyhdrdir)/$(arch)
36
+
37
+ vendorhdrdir = $(rubyhdrdir)/vendor_ruby
38
+
39
+ sitehdrdir = $(rubyhdrdir)/site_ruby
40
+
41
+ rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
42
+
43
+ vendorarchdir = $(vendorlibdir)/$(sitearch)
44
+
45
+ vendorlibdir = $(vendordir)/$(ruby_version)
46
+
47
+ vendordir = $(rubylibprefix)/vendor_ruby
48
+
49
+ sitearchdir = $(sitelibdir)/$(sitearch)
50
+
51
+ sitelibdir = $(sitedir)/$(ruby_version)
52
+
53
+ sitedir = $(rubylibprefix)/site_ruby
54
+
55
+ rubyarchdir = $(rubylibdir)/$(arch)
56
+
57
+ rubylibdir = $(rubylibprefix)/$(ruby_version)
58
+
59
+ sitearchincludedir = $(includedir)/$(sitearch)
60
+
61
+ archincludedir = $(includedir)/$(arch)
62
+
63
+ sitearchlibdir = $(libdir)/$(sitearch)
64
+
65
+ archlibdir = $(libdir)/$(arch)
66
+
67
+ ridir = $(datarootdir)/$(RI_BASE_NAME)
68
+
69
+ mandir = $(datarootdir)/man
70
+
71
+ localedir = $(datarootdir)/locale
72
+
73
+ libdir = $(exec_prefix)/lib
74
+
75
+ psdir = $(docdir)
76
+
77
+ pdfdir = $(docdir)
78
+
79
+ dvidir = $(docdir)
80
+
81
+ htmldir = $(docdir)
82
+
83
+ infodir = $(datarootdir)/info
84
+
85
+ docdir = $(datarootdir)/doc/$(PACKAGE)
86
+
87
+ oldincludedir = $(SDKROOT)/usr/include
88
+
89
+ includedir = $(prefix)/include
90
+
91
+ runstatedir = $(localstatedir)/run
92
+
93
+ localstatedir = $(prefix)/var
94
+
95
+ sharedstatedir = $(prefix)/com
96
+
97
+ sysconfdir = $(prefix)/etc
98
+
99
+ datadir = $(datarootdir)
100
+
101
+ datarootdir = $(prefix)/share
102
+
103
+ libexecdir = $(exec_prefix)/libexec
104
+
105
+ sbindir = $(exec_prefix)/sbin
106
+
107
+ bindir = $(exec_prefix)/bin
108
+
109
+ archdir = $(rubyarchdir)
110
+
111
+
112
+
113
+ CC_WRAPPER =
114
+ CC = gcc
115
+ CXX = g++
116
+ LIBRUBY = $(LIBRUBY_SO)
117
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
118
+ LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
119
+ LIBRUBYARG_STATIC = -lruby.2.6-static -framework Security -framework Foundation -lpthread -lgmp -ldl -lobjc
120
+ empty =
121
+ OUTFLAG = -o $(empty)
122
+ COUTFLAG = -o $(empty)
123
+ CSRCFLAG = $(empty)
124
+
125
+ RUBY_EXTCONF_H =
126
+ cflags = $(optflags) $(debugflags) $(warnflags)
127
+ cxxflags = $(optflags) $(debugflags) $(warnflags)
128
+ optflags = -O3
129
+ debugflags = -ggdb3
130
+ warnflags = -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wdivision-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wextra-tokens
131
+ cppflags =
132
+ CCDLFLAGS = -fno-common
133
+ CFLAGS = $(CCDLFLAGS) $(cflags) -fno-common -pipe $(ARCH_FLAG)
134
+ INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
135
+ DEFS =
136
+ CPPFLAGS = -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT $(DEFS) $(cppflags) -arch x86_64 -I/Users/anilmaurya/.rvm/gems/ruby-2.6.5/gems/rice2-2.2.1/ruby/lib/include
137
+ CXXFLAGS = $(CFLAGS) -std=c++1z -Wno-register
138
+ ldflags = -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl@1.1/lib -L/Users/anilmaurya/.rvm/gems/ruby-2.6.5/gems/rice2-2.2.1/ruby/lib/lib -lrice
139
+ dldflags = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl@1.1/lib
140
+ ARCH_FLAG =
141
+ DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
142
+ LDSHARED = g++ -std=c++14 -dynamic -bundle
143
+ LDSHAREDXX = $(CXX) -dynamic -bundle
144
+ AR = libtool -static
145
+ EXEEXT =
146
+
147
+
148
+ RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
149
+
150
+ RUBY_SO_NAME = ruby.2.6
151
+
152
+ RUBYW_INSTALL_NAME =
153
+
154
+ RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
155
+
156
+ RUBYW_BASE_NAME = rubyw
157
+
158
+ RUBY_BASE_NAME = ruby
159
+
160
+
161
+ arch = x86_64-darwin19
162
+ sitearch = $(arch)
163
+ ruby_version = 2.6.0
164
+ ruby = $(bindir)/$(RUBY_BASE_NAME)
165
+ RUBY = $(ruby)
166
+ ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h
167
+
168
+ RM = rm -f
169
+ RM_RF = $(RUBY) -run -e rm -- -rf
170
+ RMDIRS = rmdir -p
171
+ MAKEDIRS = /usr/local/opt/coreutils/bin/gmkdir -p
172
+ INSTALL = /usr/local/opt/coreutils/bin/ginstall -c
173
+ INSTALL_PROG = $(INSTALL) -m 0755
174
+ INSTALL_DATA = $(INSTALL) -m 644
175
+ COPY = cp
176
+ TOUCH = exit >
177
+
178
+ #### End of system configuration section. ####
179
+
180
+ preload =
181
+
182
+
183
+ CXX = g++ -std=c++14
184
+ libpath = . $(libdir) /usr/local/opt/libyaml/lib /usr/local/opt/readline/lib /usr/local/opt/libksba/lib /usr/local/opt/openssl@1.1/lib
185
+ LIBPATH = -L. -L$(libdir) -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl@1.1/lib
186
+ DEFFILE =
187
+
188
+ CLEANFILES = mkmf.log
189
+ DISTCLEANFILES =
190
+ DISTCLEANDIRS =
191
+
192
+ extout =
193
+ extout_prefix =
194
+ target_prefix = /fast_jsonparser
195
+ LOCAL_LIBS =
196
+ LIBS = -lruby.2.6
197
+ ORIG_SRCS = fast_jsonparser.cpp simdjson.cpp
198
+ SRCS = $(ORIG_SRCS)
199
+ OBJS = fast_jsonparser.o simdjson.o
200
+ HDRS = $(srcdir)/simdjson.h
201
+ LOCAL_HDRS =
202
+ TARGET = fast_jsonparser
203
+ TARGET_NAME = fast_jsonparser
204
+ TARGET_ENTRY = Init_$(TARGET_NAME)
205
+ DLLIB = $(TARGET).bundle
206
+ EXTSTATIC =
207
+ STATIC_LIB =
208
+
209
+ TIMESTAMP_DIR = .
210
+
211
+ BINDIR = $(bindir)
212
+
213
+ RUBYCOMMONDIR = $(sitedir)$(target_prefix)
214
+
215
+ RUBYLIBDIR = $(sitelibdir)$(target_prefix)
216
+
217
+ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
218
+
219
+ HDRDIR = $(rubyhdrdir)/ruby$(target_prefix)
220
+
221
+ ARCHHDRDIR = $(rubyhdrdir)/$(arch)/ruby$(target_prefix)
222
+
223
+ TARGET_SO_DIR =
224
+ TARGET_SO = $(TARGET_SO_DIR)$(DLLIB)
225
+ CLEANLIBS = $(TARGET_SO)
226
+ CLEANOBJS = *.o *.bak
227
+
228
+
229
+ all: $(DLLIB)
230
+ static: $(STATIC_LIB)
231
+ .PHONY: all install static install-so install-rb
232
+ .PHONY: clean clean-so clean-static clean-rb
233
+
234
+ clean-static::
235
+ clean-rb-default::
236
+ clean-rb::
237
+ clean-so::
238
+ clean: clean-so clean-static clean-rb-default clean-rb
239
+ -$(Q)$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
240
+
241
+ distclean-rb-default::
242
+ distclean-rb::
243
+ distclean-so::
244
+ distclean-static::
245
+ distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
246
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
247
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
248
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
249
+
250
+ realclean: distclean
251
+ install: install-so install-rb
252
+
253
+ install-so: $(DLLIB) $(TIMESTAMP_DIR)/.sitearchdir.-.fast_jsonparser.time
254
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
255
+ clean-static::
256
+ -$(Q)$(RM) $(STATIC_LIB)
257
+ install-rb: pre-install-rb do-install-rb install-rb-default
258
+ install-rb-default: pre-install-rb-default do-install-rb-default
259
+ pre-install-rb: Makefile
260
+ pre-install-rb-default: Makefile
261
+ do-install-rb:
262
+ do-install-rb-default:
263
+ pre-install-rb-default:
264
+ @$(NULLCMD)
265
+ $(TIMESTAMP_DIR)/.sitearchdir.-.fast_jsonparser.time:
266
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
267
+ $(Q) $(TOUCH) $@
268
+
269
+ site-install: site-install-so site-install-rb
270
+ site-install-so: install-so
271
+ site-install-rb: install-rb
272
+
273
+ .SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
274
+
275
+ .cc.o:
276
+ $(ECHO) compiling $(<)
277
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
278
+
279
+ .cc.S:
280
+ $(ECHO) translating $(<)
281
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
282
+
283
+ .mm.o:
284
+ $(ECHO) compiling $(<)
285
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
286
+
287
+ .mm.S:
288
+ $(ECHO) translating $(<)
289
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
290
+
291
+ .cxx.o:
292
+ $(ECHO) compiling $(<)
293
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
294
+
295
+ .cxx.S:
296
+ $(ECHO) translating $(<)
297
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
298
+
299
+ .cpp.o:
300
+ $(ECHO) compiling $(<)
301
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
302
+
303
+ .cpp.S:
304
+ $(ECHO) translating $(<)
305
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
306
+
307
+ .c.o:
308
+ $(ECHO) compiling $(<)
309
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
310
+
311
+ .c.S:
312
+ $(ECHO) translating $(<)
313
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
314
+
315
+ .m.o:
316
+ $(ECHO) compiling $(<)
317
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
318
+
319
+ .m.S:
320
+ $(ECHO) translating $(<)
321
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
322
+
323
+ $(TARGET_SO): $(OBJS) Makefile
324
+ $(ECHO) linking shared-object fast_jsonparser/$(DLLIB)
325
+ -$(Q)$(RM) $(@)
326
+ $(Q) $(LDSHAREDXX) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
327
+ $(Q) $(POSTLINK)
328
+
329
+
330
+
331
+ $(OBJS): $(HDRS) $(ruby_headers)
@@ -0,0 +1,101 @@
1
+ # FastJsonparser
2
+
3
+ ## Fastest Json parser for Ruby
4
+
5
+ Ruby wrapper for [simdjson](https://simdjson.org) (Parsing gigabytes of JSON per second)
6
+
7
+ Initial code imported from [simdjson_ruby](https://github.com/saka1/simdjson_ruby)
8
+
9
+ Comparison with [Oj](https://github.com/ohler55/oj) gem & JSON.parse
10
+
11
+ 1. Parsing JSON from file
12
+ ```
13
+ FastJsonparser.load(src) is 40% faster than Oj.load_file(src)
14
+ FastJsonparser.load(src) is 155% faster than JSON.parse(File.read(src))
15
+ ```
16
+ [Benchmark result](https://github.com/anilmaurya/fast_jsonparser/blob/master/benchmark/file_benchmark.rb)
17
+
18
+ ```
19
+ # virus-info.json 1.2M
20
+ # user system total real
21
+ # FastJsonparser 4.772700 0.321748 5.094448 ( 5.100354)
22
+ # OJ 6.944966 0.267082 7.212048 ( 7.253477) ~ 42% more
23
+ # standard JSON 13.311654 0.167076 13.478730 ( 13.504489) ~ 164% more
24
+ ```
25
+
26
+ 2. Parsing local JSON
27
+ ```
28
+ FastJsonparser.parse(json) is 19% faster than Oj.load(json)
29
+ FastJsonparser.parse(json) is 96% faster than JSON.parse(json)
30
+ ```
31
+ [Benchmark result](https://github.com/anilmaurya/fast_jsonparser/blob/master/benchmark/json_benchmark.rb)
32
+ ```
33
+ # user system total real
34
+ # FastJsonparser 6.732325 0.005716 6.738041 ( 6.750285)
35
+ # OJ 8.029406 0.006582 8.035988 ( 8.055000) ~ 19% more
36
+ # standard JSON 13.025884 0.031287 13.057171 ( 13.264931) ~ 96% more
37
+ ```
38
+
39
+ ## Installation
40
+
41
+ Add this line to your application's Gemfile:
42
+
43
+ ```ruby
44
+ gem 'fast_jsonparser'
45
+ ```
46
+
47
+ And then execute:
48
+
49
+ $ bundle
50
+
51
+ Or install it yourself as:
52
+
53
+ $ gem install fast_jsonparser
54
+
55
+ ## Usage
56
+
57
+ 1. Parsing JSON from file
58
+
59
+ ```
60
+ FastJsonparser.load(src) # src is source path for json file
61
+
62
+ Example:
63
+
64
+ FastJsonparser.load("./benchmark/graduation.json")
65
+
66
+ ```
67
+
68
+ 2. Parsing local JSON
69
+
70
+ ```
71
+ FastJsonparser.parse(json)
72
+
73
+ Example:
74
+
75
+ FastJsonparser.parse('{"one": 1, "two": 2}')
76
+
77
+ ```
78
+
79
+ 3. Raise FastJsonparser::ParseError when invalid JSON provided for parsing
80
+
81
+ ```
82
+ FastJsonparser.parse("123: 1") # FastJsonparser::ParseError (parse error)
83
+ ```
84
+
85
+ ## Development
86
+
87
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
88
+
89
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
90
+
91
+ ## Contributing
92
+
93
+ Bug reports and pull requests are welcome on GitHub at https://github.com/anilmaurya/fast_jsonparser. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
94
+
95
+ ## License
96
+
97
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
98
+
99
+ ## Code of Conduct
100
+
101
+ Everyone interacting in the FastJsonparser project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/fast_jsonparser/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,15 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+ require "rake/extensiontask"
4
+
5
+ Rake::ExtensionTask.new("fast_jsonparser") do |ext|
6
+ ext.lib_dir = "lib/fast_jsonparser"
7
+ end
8
+
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << "test"
11
+ t.libs << "lib"
12
+ t.test_files = FileList["test/**/*_test.rb"]
13
+ end
14
+
15
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "fast_jsonparser"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ require 'mkmf-rice'
2
+ $CXXFLAGS += ' -std=c++1z -Wno-register '
3
+
4
+
5
+ create_makefile 'fast_jsonparser/fast_jsonparser'
@@ -0,0 +1,82 @@
1
+ #include "ruby.h"
2
+
3
+ #include "simdjson.h"
4
+
5
+ VALUE rb_mFastJsonparser;
6
+
7
+ VALUE rb_eFastJsonparserParseError;
8
+
9
+ using namespace simdjson;
10
+
11
+ // Convert tape to Ruby's Object
12
+ static VALUE make_ruby_object(dom::element element) {
13
+ auto t = element.type();
14
+ if (t == dom::element_type::ARRAY) {
15
+ VALUE ary = rb_ary_new();
16
+ for (dom::element x : element) {
17
+ VALUE e = make_ruby_object(x);
18
+ rb_ary_push(ary, e);
19
+ }
20
+ return ary;
21
+ } else if (t == dom::element_type::OBJECT) {
22
+ VALUE hash = rb_hash_new();
23
+ for (dom::key_value_pair field : dom::object(element)) {
24
+ std::string_view view(field.key);
25
+ VALUE k = rb_str_new(view.data(), view.size());
26
+ VALUE v = make_ruby_object(field.value);
27
+ rb_hash_aset(hash, k, v);
28
+ }
29
+ return hash;
30
+ } else if (t == dom::element_type::INT64) {
31
+ return LONG2NUM(element.get<int64_t>());
32
+ } else if (t == dom::element_type::UINT64) {
33
+ return ULONG2NUM(element.get<uint64_t>());
34
+ } else if (t == dom::element_type::DOUBLE) {
35
+ return DBL2NUM(double(element));
36
+ } else if (t == dom::element_type::STRING) {
37
+ std::string_view view(element);
38
+ return rb_str_new(view.data(), view.size());
39
+ } else if (t == dom::element_type::BOOL) {
40
+ return bool(element) ? Qtrue : Qfalse;
41
+ } else if (t == dom::element_type::NULL_VALUE) {
42
+ return Qnil;
43
+ }
44
+ // unknown case (bug)
45
+ rb_raise(rb_eException, "[BUG] must not happen");
46
+ }
47
+
48
+ static VALUE rb_fast_jsonparser_parse(VALUE self, VALUE arg) {
49
+ Check_Type(arg, T_STRING);
50
+
51
+ dom::parser parser;
52
+ auto [doc, error] = parser.parse(RSTRING_PTR(arg), RSTRING_LEN(arg));
53
+ if (error == SUCCESS) {
54
+ return make_ruby_object(doc);
55
+ }
56
+ // TODO better error handling
57
+ rb_raise(rb_eFastJsonparserParseError, "parse error");
58
+ return Qnil;
59
+ }
60
+
61
+ static VALUE rb_fast_jsonparser_load(VALUE self, VALUE arg) {
62
+ Check_Type(arg, T_STRING);
63
+
64
+ dom::parser parser;
65
+ auto [doc, error] = parser.load(RSTRING_PTR(arg));
66
+ if (error == SUCCESS) {
67
+ return make_ruby_object(doc);
68
+ }
69
+ // TODO better error handling
70
+ rb_raise(rb_eFastJsonparserParseError, "parse error");
71
+ return Qnil;
72
+ }
73
+
74
+ extern "C" {
75
+
76
+ void Init_fast_jsonparser(void) {
77
+ rb_mFastJsonparser = rb_define_module("FastJsonparser");
78
+ rb_eFastJsonparserParseError = rb_define_class_under(rb_mFastJsonparser, "ParseError", rb_eStandardError);
79
+ rb_define_module_function(rb_mFastJsonparser, "parse", reinterpret_cast<VALUE (*)(...)>(rb_fast_jsonparser_parse), 1);
80
+ rb_define_module_function(rb_mFastJsonparser, "load", reinterpret_cast<VALUE (*)(...)>(rb_fast_jsonparser_load), 1);
81
+ }
82
+ }
@@ -0,0 +1,47 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "fast_jsonparser/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fast_jsonparser"
8
+ spec.version = FastJsonparser::VERSION
9
+ spec.authors = ["Anil Maurya"]
10
+ spec.email = ["anilmaurya8dec@gmail.com"]
11
+
12
+ spec.summary = %q{Fast Json Parser}
13
+ spec.description = %q{Fast Json Parser}
14
+ spec.homepage = "https://github.com/anilmaurya/fast_jsonparser"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "https://rubygems.com"
21
+
22
+ # spec.metadata["homepage_uri"] = spec.homepage
23
+ # spec.metadata["source_code_uri"] = "https://github.com/anilmaurya/fast_jsonparser"
24
+ # spec.metadata["changelog_uri"] = "https://github.com/anilmaurya/fast_jsonparser"
25
+ # else
26
+ # raise "RubyGems 2.0 or newer is required to protect against " \
27
+ # "public gem pushes."
28
+ # end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|benchmark|simdjson)/}) }
34
+ end
35
+ spec.files.reject! { |fn| fn.include? "simdjson" }
36
+ spec.bindir = "exe"
37
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
38
+ spec.require_paths = ["lib"]
39
+
40
+ spec.extensions << "ext/fast_jsonparser/extconf.rb"
41
+
42
+ spec.add_development_dependency "bundler", "~> 2.0"
43
+ spec.add_development_dependency "rake", "~> 10.0"
44
+ spec.add_development_dependency "minitest", "~> 5.0"
45
+ spec.add_development_dependency "rake-compiler"
46
+ spec.add_development_dependency 'oj'
47
+ end
@@ -0,0 +1,8 @@
1
+ require "fast_jsonparser/version"
2
+
3
+ module FastJsonparser
4
+ class Error < StandardError; end
5
+ # Your code goes here...
6
+ end
7
+
8
+ require "fast_jsonparser/fast_jsonparser" # loads cpp extension
@@ -0,0 +1,3 @@
1
+ module FastJsonparser
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fast_jsonparser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Anil Maurya
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-06-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake-compiler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: oj
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Fast Json Parser
84
+ email:
85
+ - anilmaurya8dec@gmail.com
86
+ executables: []
87
+ extensions:
88
+ - ext/fast_jsonparser/extconf.rb
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".travis.yml"
93
+ - CODE_OF_CONDUCT.md
94
+ - Gemfile
95
+ - Gemfile.lock
96
+ - LICENSE.txt
97
+ - Makefile
98
+ - README.md
99
+ - Rakefile
100
+ - bin/console
101
+ - bin/setup
102
+ - ext/fast_jsonparser/extconf.rb
103
+ - ext/fast_jsonparser/fast_jsonparser.cpp
104
+ - fast_jsonparser.gemspec
105
+ - lib/fast_jsonparser.rb
106
+ - lib/fast_jsonparser/fast_jsonparser.bundle
107
+ - lib/fast_jsonparser/version.rb
108
+ homepage: https://github.com/anilmaurya/fast_jsonparser
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubygems_version: 3.0.3
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Fast Json Parser
131
+ test_files: []