isomorfeus-speednode 0.6.0 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d163fe97b50cb3d23b187a384ccd95aedd2d11e7092db7e2e2866b9f882427c5
4
- data.tar.gz: a95a2273adf37112ff71263470b4dd69843e45ad69ec730611defafe20e95d02
3
+ metadata.gz: 6853c585356e8829a315a146dbf12f7625f90eb2d23683147279c5eab581fe4f
4
+ data.tar.gz: 7fd22dc8309c7d25685cc921853ac52f9ed342dac22ab71883226c2525ca48a0
5
5
  SHA512:
6
- metadata.gz: 9f8070f27aec93fa9c9059f269662a1168f2544c5c97095a472f1b1e29b55bf5d564ecd334c203146bfb9923e90a8cd94d7ea3cc0cd1a8da436f2f44cd0f73f5
7
- data.tar.gz: 05e284e4800da68388373a80620874bd624719e1baaac94633d8c61919c8c1bf4b696a6fc256eb90bfe640927a0305124306e14288483289feabb11eba439345
6
+ metadata.gz: 67668d00cf0294ed3df27c4992e95f671799cfea181cb01b33ed4c789870a7e3ab1f953c0d09e0010a8e119e6f5101aa6a31716f54d1498ca1ea5e83bfebc486
7
+ data.tar.gz: 2ea56bc9974145a6c1bab593c15001e9f7e56edb432ee38a656c2f88087ebb6935ed0f5653f4841bd362d0a70a601e01a55dcedcd9986bf5c5bae6de8257429e
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Isomorfeus Speednode<br/>
4
4
  </h1>
5
5
 
6
- A fast runtime for execjs using node js. Works on Linux, BSDs, MacOS and Windows.
6
+ A fast runtime for ExecJS using node js. Works on Linux, BSDs, MacOS and Windows.
7
7
  Inspired by [execjs-fastnode](https://github.com/jhawthorn/execjs-fastnode).
8
8
 
9
9
  ### Community and Support
@@ -59,7 +59,7 @@ Scripts can be precompiled and stored for repeated execution, which leads to a s
59
59
  ```ruby
60
60
  context = ExecJS.compile('Test = "test"')
61
61
  context.add_script(key: 'super', source: some_large_javascript) # will compile and store the script
62
- context.eval_script(:key: 'super') # will run the precompiled script in the context
62
+ context.eval_script(key: 'super') # will run the precompiled script in the context
63
63
  ```
64
64
  For the actual performance benefit see below.
65
65
 
@@ -96,38 +96,28 @@ Attaching and calling ruby methods to/from permissive contexts is not that fast.
96
96
 
97
97
  Highly scientific, maybe.
98
98
 
99
- 1000 rounds using node 16.14.0 on linux (ctx = using context, scsc = using precompiled scripts):
99
+ 1000 rounds using isomorfeus-speednode 0.6.1 with node 18.15.0 on a older CPU on Linux
100
+ (ctx = using context, scsc = using precompiled scripts):
100
101
  ```
101
102
  standard ExecJS CoffeeScript eval benchmark:
102
- user system total real
103
- Isomorfeus Speednode Node.js (V8): 0.086443 0.061089 0.147532 ( 0.567715)
104
- Isomorfeus Speednode Node.js (V8) ctx: 0.080821 0.047469 0.128290 ( 0.468664)
105
- Isomorfeus Speednode Node.js (V8) scsc: 0.089423 0.046541 0.135964 ( 0.381198) <- fastest
106
- mini_racer (V8): 0.723352 0.179944 0.903296 ( 0.513696)
107
- mini_racer (V8) ctx: 0.475681 0.226101 0.701782 ( 0.429463)
103
+ user system total real
104
+ Isomorfeus Speednode Node.js (V8): 0.107551 0.024227 0.131778 ( 1.034893)
105
+ Isomorfeus Speednode Node.js (V8) ctx: 0.081142 0.064432 0.145574 ( 0.878249)
106
+ Isomorfeus Speednode Node.js (V8) scsc: 0.058941 0.040266 0.099207 ( 0.525479)
107
+ mini_racer (0.6.3, libv8-node 16.10.0): 0.563453 0.416156 0.979609 ( 0.628226)
108
+ mini_racer (0.6.3, libv8-node 16.10.0) ctx: 0.393274 0.187259 0.580533 ( 0.434056)
108
109
 
109
110
  eval overhead benchmark:
110
- user system total real
111
- Isomorfeus Speednode Node.js (V8): 0.028312 0.062895 0.091207 ( 0.199176)
112
- Isomorfeus Speednode Node.js (V8) ctx: 0.061245 0.027093 0.088338 ( 0.183092)
113
- Isomorfeus Speednode Node.js (V8) scsc: 0.061062 0.019203 0.080265 ( 0.107898) <- fastest
114
- mini_racer (V8): 0.103914 0.092251 0.196165 ( 0.125081)
115
- mini_racer (V8) ctx: 0.120440 0.060329 0.180769 ( 0.112695)
116
-
117
- ```
118
- minify discourse benchmark from mini_racer:
119
- ```
120
- minify discourse_app_minified.js:
121
- user system total real
122
- isomorfeus-speednode Windows 0.016000 0.078000 0.094000 ( 11.828518)
123
- isomorfeus-speednode Linux 0.043747 0.000000 15.931284 ( 11.860528)
124
- mini_racer 0.043471 0.000000 15.974214 ( 11.923735)
125
- node 0.043695 0.000000 15.812040 ( 11.781835)
111
+ user system total real
112
+ Isomorfeus Speednode Node.js (V8): 0.065491 0.026181 0.091672 ( 0.196204)
113
+ Isomorfeus Speednode Node.js (V8) ctx: 0.060876 0.029535 0.090411 ( 0.197763)
114
+ Isomorfeus Speednode Node.js (V8) scsc: 0.036967 0.045451 0.082418 ( 0.133337)
115
+ mini_racer (0.6.3, libv8-node 16.10.0): 0.070333 0.056378 0.126711 ( 0.100380)
116
+ mini_racer (0.6.3, libv8-node 16.10.0) ctx: 0.072719 0.049049 0.121768 ( 0.095643)
126
117
  ```
127
118
 
128
119
  To run benchmarks:
129
120
  - clone repo
130
- - `cd ruby`
131
121
  - `bundle install`
132
122
  - `bundle exec rake bench`
133
123
 
@@ -135,6 +125,5 @@ To run benchmarks:
135
125
 
136
126
  To run tests:
137
127
  - clone repo
138
- - `cd ruby`
139
128
  - `bundle install`
140
- - `bundle exec rake test`
129
+ - `bundle exec rake`
@@ -223,4 +223,4 @@ module Isomorfeus
223
223
  end
224
224
  end
225
225
  end
226
- end
226
+ end
@@ -133,69 +133,69 @@ CircularJSON.stringify = function stringify(value, replacer, space, doNotResolve
133
133
  /*** end of circular-json ***/
134
134
 
135
135
  function attachFunctionSource(responder_path, context, func) {
136
- return func + " = async function(...method_args) {\n\
137
- let context = \"" + context + "\";\n\
138
- let func = \"" + func +"\";\n\
139
- let request = [context, func, method_args];\n\
140
- let responder_path = '" + responder_path + "';\n\
141
- if (!global.__responder_socket) {\n\
142
- return new Promise(function(resolve, reject) {\n\
143
- setTimeout(function(){\n\
144
- if (os.platform().indexOf('win') == 0) {\n\
145
- let socket = net.connect(responder_path);\n\
146
- socket.on('connect', function(){\n\
147
- global.__responder_socket = true;\n\
148
- socket.destroy();\n\
149
- resolve(" + func + "(...method_args));\n\
150
- })\n\
151
- socket.on('error', function (err) {\n\
152
- resolve(" + func + "(...method_args));\n\
153
- });\n\
154
- } else {\n\
155
- if (fs.existsSync(responder_path)) { global.__responder_socket = true; }\n\
156
- resolve(" + func + "(...method_args));\n\
157
- }\n\
158
- }, 10)\n\
159
- });\n\
160
- }\n\
161
- return new Promise(function(resolve, reject) {\n\
162
- let request_json = JSON.stringify(request);\n\
163
- let buffer = Buffer.alloc(0);\n\
164
- let socket = net.connect(responder_path);\n\
165
- socket.setTimeout(2000);\n\
166
- socket.on('error', function (err) {\n\
167
- if (err.syscall === 'connect') {\n\
168
- // ignore, close will handle\n\
169
- } else if ((os.platform().indexOf('win') == 0) && err.message.includes('read EPIPE')) {\n\
170
- // ignore, close will handle\n\
171
- } else if ((os.platform().indexOf('win') == 0) && err.message.includes('write EPIPE')) {\n\
172
- // ignore, close will handle\n\
173
- } else { reject(err); }\n\
174
- });\n\
175
- socket.on('ready', function () {\n\
176
- socket.write(request_json + \"\x04\");\n\
177
- });\n\
178
- socket.on('data', function (data) {\n\
179
- buffer = Buffer.concat([buffer, data]);\n\
180
- });\n\
181
- socket.on('timeout', function() {\n\
182
- socket.destroy();\n\
183
- reject();\n\
184
- });\n\
185
- socket.on('close', function() {\n\
186
- if (buffer.length > 0) {\n\
187
- let method_result = JSON.parse(buffer.toString('utf8'));\n\
188
- if (method_result[0] == 'err') {\n\
189
- reject(method_result);\n\
190
- } else {\n\
191
- resolve(method_result[1]);\n\
192
- }\n\
193
- } else {\n\
194
- resolve(null);\n\
195
- }\n\
196
- });\n\
197
- });\n\
198
- }\n";
136
+ return `${func} = async function(...method_args) {
137
+ let context = '${context}';
138
+ let func = '${func}';
139
+ let request = [context, func, method_args];
140
+ let responder_path = '${responder_path}';
141
+ if (!global.__responder_socket) {
142
+ return new Promise(function(resolve, reject) {
143
+ setTimeout(function(){
144
+ if (os.platform() == 'win32') {
145
+ let socket = net.connect(responder_path);
146
+ socket.on('connect', function(){
147
+ global.__responder_socket = true;
148
+ socket.destroy();
149
+ resolve(${func}(...method_args));
150
+ })
151
+ socket.on('error', function (err) {
152
+ resolve(${func}(...method_args));
153
+ });
154
+ } else {
155
+ if (fs.existsSync(responder_path)) { global.__responder_socket = true; }
156
+ resolve(${func}(...method_args));
157
+ }
158
+ }, 10)
159
+ });
160
+ }
161
+ return new Promise(function(resolve, reject) {
162
+ let request_json = JSON.stringify(request);
163
+ let buffer = Buffer.alloc(0);
164
+ let socket = net.connect(responder_path);
165
+ socket.setTimeout(2000);
166
+ socket.on('error', function (err) {
167
+ if (err.syscall === 'connect') {
168
+ // ignore, close will handle
169
+ } else if ((os.platform() == 'win32') && err.message.includes('read EPIPE')) {
170
+ // ignore, close will handle
171
+ } else if ((os.platform() == 'win32') && err.message.includes('write EPIPE')) {
172
+ // ignore, close will handle
173
+ } else { reject(err); }
174
+ });
175
+ socket.on('ready', function () {
176
+ socket.write(request_json + "\x04");
177
+ });
178
+ socket.on('data', function (data) {
179
+ buffer = Buffer.concat([buffer, data]);
180
+ });
181
+ socket.on('timeout', function() {
182
+ socket.destroy();
183
+ reject();
184
+ });
185
+ socket.on('close', function() {
186
+ if (buffer.length > 0) {
187
+ let method_result = JSON.parse(buffer.toString('utf8'));
188
+ if (method_result[0] == 'err') {
189
+ reject(method_result);
190
+ } else {
191
+ resolve(method_result[1]);
192
+ }
193
+ } else {
194
+ resolve(null);
195
+ }
196
+ });
197
+ });
198
+ }`;
199
199
  }
200
200
 
201
201
  function createCompatibleContext(uuid, options) {
@@ -261,7 +261,7 @@ let commands = {
261
261
  attach: function(input) {
262
262
  let context = getContext(input.context);
263
263
  let responder_path;
264
- if (os.platform().indexOf('win') == 0) { responder_path = '\\\\\\\\.\\\\pipe\\\\' + socket_path + '_responder'; }
264
+ if (process.platform == 'win32') { responder_path = '\\\\\\\\.\\\\pipe\\\\' + socket_path + '_responder'; }
265
265
  else { responder_path = socket_path + '_responder' }
266
266
  let result = vm.runInContext(attachFunctionSource(responder_path, input.context, input.func), context, { filename: "(execjs)", displayErrors: true });
267
267
  return formatResult(result);
@@ -319,15 +319,15 @@ let commands = {
319
319
  }
320
320
  },
321
321
  eval: function (input) {
322
- if (input.source.match(/^\s*{/)) { input.source = "(" + input.source + ")"; }
323
- else if (input.source.match(/^\s*function\s*\(/)) { input.source = "(" + input.source + ")"; }
322
+ if (input.source.match(/^\s*{/)) { input.source = `(${input.source})`; }
323
+ else if (input.source.match(/^\s*function\s*\(/)) { input.source = `(${input.source})`; }
324
324
  let result = vm.runInContext(input.source, getContext(input.context), getContextOptions(input.context));
325
325
  return formatResult(result);
326
326
  },
327
327
  evald: function(input) {
328
328
  if (debug_contexts.includes(input.context)) {
329
- if (input.source.match(/^\s*{/)) { input.source = "(" + input.source + ")"; }
330
- else if (input.source.match(/^\s*function\s*\(/)) { input.source = "(" + input.source + ")"; }
329
+ if (input.source.match(/^\s*{/)) { input.source = `(${input.source})`; }
330
+ else if (input.source.match(/^\s*function\s*\(/)) { input.source = `(${input.source})`; }
331
331
  let result = eval(input.source);
332
332
  return formatResult(result);
333
333
  } else {
@@ -399,5 +399,5 @@ let server = net.createServer(function(s) {
399
399
  });
400
400
  });
401
401
 
402
- if (os.platform().indexOf('win') == 0) { server.listen('\\\\.\\pipe\\' + socket_path); }
402
+ if (process.platform == 'win32') { server.listen('\\\\.\\pipe\\' + socket_path); }
403
403
  else { server.listen(socket_path); }
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Speednode
3
- VERSION = '0.6.0'
3
+ VERSION = '0.6.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-speednode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-27 00:00:00.000000000 Z
11
+ date: 2023-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs
@@ -28,16 +28,22 @@ dependencies:
28
28
  name: oj
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 3.13.23
34
+ - - "<"
32
35
  - !ruby/object:Gem::Version
33
- version: 3.13.21
36
+ version: 3.16.0
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - "~>"
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 3.13.23
44
+ - - "<"
39
45
  - !ruby/object:Gem::Version
40
- version: 3.13.21
46
+ version: 3.16.0
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: win32-pipe
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +78,14 @@ dependencies:
72
78
  requirements:
73
79
  - - "~>"
74
80
  - !ruby/object:Gem::Version
75
- version: 5.16.0
81
+ version: 5.18.1
76
82
  type: :development
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
86
  - - "~>"
81
87
  - !ruby/object:Gem::Version
82
- version: 5.16.0
88
+ version: 5.18.1
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: rake
85
91
  requirement: !ruby/object:Gem::Requirement
@@ -151,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
157
  - !ruby/object:Gem::Version
152
158
  version: '0'
153
159
  requirements: []
154
- rubygems_version: 3.4.0.dev
160
+ rubygems_version: 3.4.10
155
161
  signing_key:
156
162
  specification_version: 4
157
163
  summary: A fast ExecJS runtime based on nodejs, tuned for Isomorfeus.