-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
522 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/styles/default.min.css"> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.9.0/highlight.min.js"></script> | ||
<script src="https://cdn.rawgit.com/bestiejs/benchmark.js/2.1.3/benchmark.js"></script> | ||
<script src="https://cdn.rawgit.com/dcodeIO/long.js/3.2.0/dist/long.min.js"></script> | ||
<script src="https://cdn.rawgit.com/dcodeIO/protobuf.js/master/dist/protobuf.min.js"></script> | ||
<script> | ||
var data = { | ||
"string" : "Lorem ipsum dolor sit amet.", | ||
"uint32" : 9000, | ||
"inner" : { | ||
"int32" : 20161110, | ||
"innerInner" : { | ||
"long" : { | ||
"low": 1051, | ||
"high": 151234, | ||
"unsigned": false | ||
}, | ||
"enum" : 1, | ||
"sint32": -42 | ||
}, | ||
"outer" : { | ||
"bool" : [ true, false, false, true, false, false, true ], | ||
"double": 204.8 | ||
} | ||
}, | ||
"float": 0.25 | ||
}; | ||
|
||
var root = protobuf.parse("syntax = \"proto3\";\ | ||
message Test {\ | ||
string string = 1;\ | ||
uint32 uint32 = 2;\ | ||
Inner inner = 3;\ | ||
float float = 4;\ | ||
message Inner {\ | ||
int32 int32 = 1;\ | ||
InnerInner innerInner = 2;\ | ||
Outer outer = 3;\ | ||
message InnerInner {\ | ||
int64 long = 1;\ | ||
Enum enum = 2;\ | ||
sint32 sint32 = 3;\ | ||
}\ | ||
}\ | ||
enum Enum {\ | ||
ONE = 0;\ | ||
TWO = 1;\ | ||
THREE = 2;\ | ||
FOUR = 3;\ | ||
FIVE = 4;\ | ||
}\ | ||
}\ | ||
message Outer {\ | ||
repeated bool bool = 1;\ | ||
double double = 2;\ | ||
}").root; | ||
|
||
var Test = root.lookup("Test"); | ||
var buf = Test.encode(data).finish(); | ||
var msg = Test.fromObject(data); | ||
var obj = Test.toObject(msg); | ||
|
||
var tests = { | ||
"encoding": { | ||
"Test.encode": "Test.encode(data).finish();", | ||
"JSON.stringify": "JSON.stringify(data)" | ||
}, | ||
"Test.decode": "Test.decode(buf);", | ||
"Test.encode + decode": "Test.decode(Test.encode(data).finish());", | ||
"Test.verify": "Test.verify(data);", | ||
"Test.fromObject": "Test.fromObject(obj);", | ||
"Test.toObject": "Test.toObject(msg);" | ||
}; | ||
</script> | ||
<style>body { font-family: sans-serif; } h2 { font-size: 1em; }</style> | ||
</head> | ||
<body> | ||
<h1>protobuf.js browser benchmark</h1> | ||
<script> | ||
Object.keys(tests).forEach(function(name) { | ||
document.write("<h2>" + name + "</h2>"); | ||
document.write("<pre><code class=\"javascript\">" + tests[name] + "</code></pre>"); | ||
}); | ||
hljs.initHighlightingOnLoad(); | ||
</script> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.