File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ profile-decode:
31
31
node --prof-process --preprocess -j isolate-* .log | npx flamebearer
32
32
33
33
benchmark :
34
- npx ts-node benchmark/benchmark-from-msgpack-lite.ts
34
+ npx node -r ts-node/register benchmark/benchmark-from-msgpack-lite.ts
35
35
@echo
36
36
node benchmark/msgpack-benchmark.js
37
37
Original file line number Diff line number Diff line change @@ -42,8 +42,7 @@ var buf, obj;
42
42
43
43
if ( JSON ) {
44
44
buf = bench ( 'buf = Buffer.from(JSON.stringify(obj));' , JSON_stringify , data ) ;
45
- buf = bench ( 'buf = JSON.stringify(obj);' , JSON . stringify , data ) ;
46
- obj = bench ( 'obj = JSON.parse(buf);' , JSON . parse , buf ) ;
45
+ obj = bench ( 'obj = JSON.parse(buf.toString("utf-8"));' , JSON_parse , buf ) ;
47
46
runTest ( obj ) ;
48
47
}
49
48
@@ -100,10 +99,14 @@ if (notepack) {
100
99
runTest ( obj ) ;
101
100
}
102
101
103
- function JSON_stringify ( src : any ) {
102
+ function JSON_stringify ( src : any ) : Buffer {
104
103
return Buffer . from ( JSON . stringify ( src ) ) ;
105
104
}
106
105
106
+ function JSON_parse ( json : Buffer ) : any {
107
+ return JSON . parse ( json . toString ( "utf-8" ) ) ;
108
+ }
109
+
107
110
function bench ( name : string , func : ( ...args : any [ ] ) => any , src : any ) {
108
111
if ( argv . length ) {
109
112
var match = argv . filter ( function ( grep ) {
You can’t perform that action at this time.
0 commit comments