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:
3131 node --prof-process --preprocess -j isolate-* .log | npx flamebearer
3232
3333benchmark :
34- npx ts-node benchmark/benchmark-from-msgpack-lite.ts
34+ npx node -r ts-node/register benchmark/benchmark-from-msgpack-lite.ts
3535 @echo
3636 node benchmark/msgpack-benchmark.js
3737
Original file line number Diff line number Diff line change @@ -42,8 +42,7 @@ var buf, obj;
4242
4343if ( JSON ) {
4444 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 ) ;
4746 runTest ( obj ) ;
4847}
4948
@@ -100,10 +99,14 @@ if (notepack) {
10099 runTest ( obj ) ;
101100}
102101
103- function JSON_stringify ( src : any ) {
102+ function JSON_stringify ( src : any ) : Buffer {
104103 return Buffer . from ( JSON . stringify ( src ) ) ;
105104}
106105
106+ function JSON_parse ( json : Buffer ) : any {
107+ return JSON . parse ( json . toString ( "utf-8" ) ) ;
108+ }
109+
107110function bench ( name : string , func : ( ...args : any [ ] ) => any , src : any ) {
108111 if ( argv . length ) {
109112 var match = argv . filter ( function ( grep ) {
You can’t perform that action at this time.
0 commit comments