Skip to content

Update to work with Dart 2 #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions example/benchmark.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ main(List<String> args) async {
"hello": "world"
});

var json = JSON.encode({
var jsonStr = json.encode({
"hello": "world"
});

unpack(packed);
JSON.decode(json);
json.decode(jsonStr);
}

if (args.contains("--savings")) {
Expand All @@ -48,7 +48,7 @@ main(List<String> args) async {
numbers.add(i);
}

var jsonBytes = UTF8.encode(JSON.encode(numbers)).length;
var jsonBytes = utf8.encode(json.encode(numbers)).length;
var msgpackBytes = pack(numbers).length;
var fract = new Fraction(jsonBytes, msgpackBytes);
fract = fract.reduce();
Expand Down Expand Up @@ -249,7 +249,7 @@ main(List<String> args) async {

testObjectDecode(String desc, input) {
print("${desc}:");
var packedJson = JSON.encode(input);
var packedJson = json.encode(input);
var packed = pack(input);
var watch = new Stopwatch();
var times = [];
Expand All @@ -274,7 +274,7 @@ testObjectDecode(String desc, input) {
for (var i = 1; i <= TIMES; i++) {
watch.reset();
watch.start();
JSON.decode(packedJson);
json.decode(packedJson);
watch.stop();
times.add(watch.elapsedMicroseconds);
}
Expand Down Expand Up @@ -320,12 +320,12 @@ testObjectEncode(String desc, input) {
print(" Shortest Time: ${times.first} microseconds (${times.first / 1000}ms)");
print(" Size: ${size} bytes");
watch.reset();
size = UTF8.encode(JSON.encode(input)).length;
size = utf8.encode(json.encode(input)).length;
times.clear();
for (var i = 1; i <= TIMES; i++) {
watch.reset();
watch.start();
JSON.encode(input);
json.encode(input);
watch.stop();
times.add(watch.elapsedMicroseconds);
}
Expand Down
7 changes: 5 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: msgpack
description: MsgPack for Dart
version: 0.9.0
version: 0.10.0
authors:
- Kenneth Endfinger <[email protected]>
- Dan Ellis <[email protected]>
- Matthew Butler <[email protected]>
homepage: https://github.com/DirectMyFile/msgpack.dart
environment:
sdk: ">=2.0.0 <3.0.0"
dev_dependencies:
test: "^0.12.0"
test: ^1.3.0
4 changes: 2 additions & 2 deletions test/msgpack_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ var isList = predicate((e) => e is List, 'is a List');
class TestMessage extends Message {
int a;
String b;
Map<int, String> c;
Map c;

TestMessage(this.a, this.b, this.c);

Expand All @@ -22,7 +22,7 @@ class TestMessage extends Message {
class OuterMessage extends Message {
String a;
bool b;
List<int> list;
List list;
TestMessage inner;

OuterMessage(this.a, this.b, this.list, this.inner);
Expand Down