Skip to content

Commit 76e5b6e

Browse files
committed
move benchmark things to benchmark/ and add msgpack-benchmark.js
1 parent c022de5 commit 76e5b6e

File tree

6 files changed

+312
-25
lines changed

6 files changed

+312
-25
lines changed

benchmark/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock.json

benchmark/msgpack-benchmark.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/* eslint-disable no-console */
2+
// based on https://github.com/endel/msgpack-benchmark
3+
"use strict";
4+
5+
const Benchmark = require("benchmark");
6+
const fs = require("fs");
7+
const msgpack = require("..");
8+
9+
const implementations = {
10+
"@msgpack/msgpack": {
11+
encode: require("..").encode,
12+
decode: require("..").decode,
13+
},
14+
"msgpack-lite": {
15+
encode: require("msgpack-lite").encode,
16+
decode: require("msgpack-lite").decode,
17+
},
18+
"notepack.io": {
19+
encode: require("notepack.io").encode,
20+
decode: require("notepack.io").decode,
21+
},
22+
};
23+
24+
// exactly the same as:
25+
// https://raw.githubusercontent.com/endel/msgpack-benchmark/master/sample-large.json
26+
const sampleFiles = ["./sample-large.json"];
27+
28+
function validate(name, data, encoded) {
29+
if (JSON.stringify(data) !== JSON.stringify(implementations[name].decode(encoded))) {
30+
throw new Error("Bad implementation: " + name);
31+
}
32+
}
33+
34+
for (const sampleFile of sampleFiles) {
35+
const data = require(sampleFile);
36+
const encodeSuite = new Benchmark.Suite();
37+
const decodeSuite = new Benchmark.Suite();
38+
39+
console.log("");
40+
console.log("**" + sampleFile + ":** (" + JSON.stringify(data).length + " bytes in JSON)");
41+
console.log("");
42+
43+
for (const name of Object.keys(implementations)) {
44+
implementations[name].toDecode = implementations[name].encode(data);
45+
validate(name, data, implementations[name].toDecode);
46+
encodeSuite.add("(encode) " + name, () => {
47+
implementations[name].encode(data);
48+
});
49+
decodeSuite.add("(decode) " + name, () => {
50+
implementations[name].decode(implementations[name].toDecode);
51+
});
52+
}
53+
encodeSuite.on("cycle", (event) => {
54+
console.log(String(event.target));
55+
});
56+
57+
console.log("```");
58+
encodeSuite.run();
59+
console.log("```");
60+
61+
console.log("");
62+
63+
decodeSuite.on("cycle", function(event) {
64+
console.log(String(event.target));
65+
});
66+
67+
console.log("```");
68+
decodeSuite.run();
69+
console.log("```");
70+
}

benchmark/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "@msgpack/msgpack-benchmark",
3+
"private": true,
4+
"version": "0",
5+
"dependencies": {
6+
"benchmark": "^2.1.4",
7+
"msgpack-lite": "^0.1.26",
8+
"notepack.io": "^2.2.0"
9+
}
10+
}

benchmark/sample-large.json

Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
[
2+
{
3+
"_id":"56490c18d9275a0003000000",
4+
"author":null,
5+
"created_at":"2015-11-15T22:50:00.170Z",
6+
"description":"A weekly discussion by Ruby developers about programming, life, and careers.",
7+
"image":"https://s3.amazonaws.com/devchat.tv/ruby-rogues-thumb.jpg",
8+
"keywords":[
9+
"Business",
10+
"Careers",
11+
"Technology",
12+
"Software How-To"
13+
],
14+
"language":"en",
15+
"permalink":"http://rubyrogues.com/",
16+
"published":true,
17+
"title":"The Ruby Rogues",
18+
"updated_at":"2015-11-15T22:50:06.565Z",
19+
"url":"http://feeds.feedwrench.com/RubyRogues.rss"
20+
},
21+
{
22+
"_id":"56490d6ad9275a00030000eb",
23+
"author":null,
24+
"created_at":"2015-11-15T22:55:38.074Z",
25+
"description":"Um podcast feito para programadores e empreendedores.",
26+
"image":"http://www.grokpodcast.com/images/logo_itunes_grande.png",
27+
"keywords":[
28+
"Technology",
29+
"Podcasting",
30+
"Business",
31+
"Careers"
32+
],
33+
"language":"pt-BR",
34+
"permalink":"http://www.grokpodcast.com/",
35+
"published":true,
36+
"title":"Grok Podcast",
37+
"updated_at":"2015-11-15T22:55:47.498Z",
38+
"url":"http://www.grokpodcast.com/atom.xml"
39+
},
40+
{
41+
"_id":"564a1c30b1191d0003000000",
42+
"author":null,
43+
"created_at":"2015-11-16T18:10:56.610Z",
44+
"description":"The Web Platform Podcast is a developer discussion that dives deep into ‘all things’ web. We discuss everything from developing for mobile to building HDTV software. From wearables \u0026 robotics to user experience \u0026 mentoring, we bring to our listeners everything related to building products \u0026 services for The Web Platform of today, tomorrow, and beyond.",
45+
"image":"http://static.libsyn.com/p/assets/f/7/2/0/f7208dae16d0543e/twp-logo-flat-blue-square.png",
46+
"keywords":[
47+
"Technology",
48+
"Software How-To",
49+
"Tech News"
50+
],
51+
"language":"en",
52+
"permalink":"http://thewebplatform.libsyn.com/webpage",
53+
"published":true,
54+
"title":"The Web Platform Podcast",
55+
"updated_at":"2015-11-16T18:11:02.022Z",
56+
"url":"http://thewebplatform.libsyn.com//rss"
57+
},
58+
{
59+
"_id":"564a1de3b1191d0003000047",
60+
"author":null,
61+
"created_at":"2015-11-16T18:18:11.854Z",
62+
"description":"Developer Tea is a podcast for web and software developers hosted by a developer that you can listen to in less than 10 minutes. The show will cover a wide variety of topics related to the career of being a developer. We hope you'll take the topics from this podcast and continue the conversation, either online or in person with your peers. The show is hosted by Jonathan Cutrell, Director of Technology at Whiteboard and the author of Hacking the Impossible, a developer's guide to working with visionaries. :: Twitter: @developertea @jcutrell :: Email: developertea@gmail.com",
63+
"image":"http://simplecast-media.s3.amazonaws.com/podcast/image/363/1440374119-artwork.jpg",
64+
"keywords":[
65+
"Technology",
66+
"Business",
67+
"Careers",
68+
"Society \u0026 Culture"
69+
],
70+
"language":"en-us",
71+
"permalink":"http://www.developertea.com/",
72+
"published":true,
73+
"title":"Developer Tea",
74+
"updated_at":"2015-11-16T23:00:23.224Z",
75+
"url":"http://feeds.feedburner.com/developertea"
76+
},
77+
{
78+
"_id":"564a3163e51cc0000300004c",
79+
"author":null,
80+
"created_at":"2015-11-16T19:41:23.436Z",
81+
"description":"Conference talks from the Remote Conferences series put on by Devchat.tv",
82+
"image":"https://s3.amazonaws.com/devchat.tv/RemoteConfs.jpg",
83+
"keywords":[
84+
85+
],
86+
"language":"en",
87+
"permalink":"http://remoteconfs.com/",
88+
"published":true,
89+
"title":"Remote Conferences - Audio",
90+
"updated_at":"2015-11-16T19:41:24.367Z",
91+
"url":"http://feeds.feedwrench.com/remoteconfs-audio.rss"
92+
},
93+
{
94+
"_id":"564a315de51cc00003000000",
95+
"author":null,
96+
"created_at":"2015-11-16T19:41:17.492Z",
97+
"description":"Weekly discussion by freelancers and professionals about running a business, finding clients, marketing, and lifestyle related to being a freelancer.",
98+
"image":"https://s3.amazonaws.com/devchat.tv/freelancers_show_thumb.jpg",
99+
"keywords":[
100+
"Business",
101+
"Careers",
102+
"Management \u0026amp; Marketing",
103+
"Education",
104+
"Training"
105+
],
106+
"language":"en",
107+
"permalink":"http://www.freelancersshow.com/",
108+
"published":true,
109+
"title":"The Freelancers' Show",
110+
"updated_at":"2015-11-16T19:41:27.459Z",
111+
"url":"http://feeds.feedwrench.com/TheFreelancersShow.rss"
112+
},
113+
{
114+
"_id":"564a3169e51cc000030000cd",
115+
"author":null,
116+
"created_at":"2015-11-16T19:41:29.686Z",
117+
"description":"React Native Radio Podcast",
118+
"image":"https://s3.amazonaws.com/devchat.tv/react-native-radio-album-art.jpg",
119+
"keywords":[
120+
121+
],
122+
"language":"en",
123+
"permalink":"http://devchat.tv/react-native-radio",
124+
"published":true,
125+
"title":"React Native Radio",
126+
"updated_at":"2015-11-16T19:41:29.999Z",
127+
"url":"http://feeds.feedwrench.com/react-native-radio.rss"
128+
},
129+
{
130+
"_id":"564a316fe51cc000030000d4",
131+
"author":null,
132+
"created_at":"2015-11-16T19:41:35.937Z",
133+
"description":"The iOS Development Podcast",
134+
"image":"https://s3.amazonaws.com/devchat.tv/iPhreaks-thumb.jpg",
135+
"keywords":[
136+
"Technology",
137+
"Tech News",
138+
"Software How-To"
139+
],
140+
"language":"en",
141+
"permalink":"http://iphreaksshow.com/",
142+
"published":true,
143+
"title":"The iPhreaks Show",
144+
"updated_at":"2015-11-16T19:41:43.700Z",
145+
"url":"http://feeds.feedwrench.com/iPhreaks.rss"
146+
},
147+
{
148+
"_id":"564a3184e51cc00003000156",
149+
"author":null,
150+
"created_at":"2015-11-16T19:41:56.874Z",
151+
"description":"Weekly podcast discussion about Javascript on the front and back ends. Also discuss programming practices, coding environments, and the communities related to the technology.",
152+
"image":"https://s3.amazonaws.com/devchat.tv/javascript_jabber_thumb.jpg",
153+
"keywords":[
154+
"Education",
155+
"Training",
156+
"Technology",
157+
"Software How-To"
158+
],
159+
"language":"en",
160+
"permalink":"http://javascriptjabber.com/",
161+
"published":true,
162+
"title":"JavaScript Jabber",
163+
"updated_at":"2015-11-16T19:42:24.692Z",
164+
"url":"http://feeds.feedwrench.com/JavaScriptJabber.rss"
165+
},
166+
{
167+
"_id":"564a31dee51cc00003000210",
168+
"author":null,
169+
"created_at":"2015-11-16T19:43:26.390Z",
170+
"description":"Each week we explore an aspect of web security.",
171+
"image":"http://devchat.cachefly.net/websecwarriors/logo_3000x3000.jpeg",
172+
"keywords":[
173+
174+
],
175+
"language":"en",
176+
"permalink":"http://websecuritywarriors.com/",
177+
"published":true,
178+
"title":"Web Security Warriors",
179+
"updated_at":"2015-11-16T19:43:28.133Z",
180+
"url":"http://feeds.feedwrench.com/websecwarriors.rss"
181+
},
182+
{
183+
"_id":"564a3ddbe51cc00003000217",
184+
"author":null,
185+
"created_at":"2015-11-16T20:34:35.791Z",
186+
"description":"Podcasts produzidos de 2008 a 2010 sobre jogos e todos os tipos de assuntos relacionados ao universo e cultura dos vídeogames.",
187+
"image":"http://jogabilida.de/wp-content/uploads/2011/12/nl-podcast.png",
188+
"keywords":[
189+
"Games \u0026 Hobbies",
190+
"Video Games"
191+
],
192+
"language":"pt-BR",
193+
"permalink":"http://jogabilida.de/",
194+
"published":true,
195+
"title":"Podcast NowLoading",
196+
"updated_at":"2015-11-16T23:00:23.963Z",
197+
"url":"http://feeds.feedburner.com/podcastnowloading"
198+
},
199+
{
200+
"_id":"564b9cfe08602e00030000fa",
201+
"author":null,
202+
"created_at":"2015-11-17T21:32:46.210Z",
203+
"description":"Being Boss is a podcast for creative entrepreneurs. From Emily Thompson and Kathleen Shannon. Get your business together. Being boss is hard. Making a dream job of your own isn't easy. But getting paid for it, becoming known for it, and finding purpose in it, is so doable - if you do the work.",
204+
"image":"http://www.lovebeingboss.com/img/skin/Header_WhiteLogo.png",
205+
"keywords":[
206+
207+
],
208+
"language":null,
209+
"permalink":"http://www.lovebeingboss.com/",
210+
"published":true,
211+
"title":"Being Boss // A Podcast for Creative Entrepreneurs",
212+
"updated_at":"2015-11-17T21:32:50.672Z",
213+
"url":"http://www.lovebeingboss.com/RSSRetrieve.aspx?ID=18365\u0026Type=RSS20"
214+
},
215+
{
216+
"_id":"564c5c8008602e0003000128",
217+
"author":null,
218+
"created_at":"2015-11-18T11:09:52.991Z",
219+
"description":"O mundo pop vira piada no Jovem Nerd",
220+
"image":"http://jovemnerd.ig.com.br/wp-content/themes/jovemnerd_v2b/images/NC_FEED.jpg",
221+
"keywords":[
222+
"Society \u0026 Culture"
223+
],
224+
"language":"pt-BR",
225+
"permalink":"http://jovemnerd.com.br/",
226+
"published":true,
227+
"title":"Nerdcast",
228+
"updated_at":"2015-11-18T11:11:20.034Z",
229+
"url":"http://jovemnerd.com.br/categoria/nerdcast/feed/"
230+
}
231+
]

package-lock.json

Lines changed: 0 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
"karma-webpack": "^3.0.5",
7474
"lodash": "^4.17.11",
7575
"mocha": "^6.1.4",
76-
"msgpack-lite": "^0.1.26",
7776
"msgpack-test-js": "^1.0.0",
7877
"npm-run-all": "^4.1.5",
7978
"prettier": "^1.17.1",

0 commit comments

Comments
 (0)