-
-
Notifications
You must be signed in to change notification settings - Fork 53
Benchmark
Pascal S. de Kloe edited this page Oct 31, 2023
·
15 revisions
Colfer's own benchmarks use the following 4 data samples.
var testData = []*Colfer{
{Key: 1234567890, Host: "db003lz12", Port: 389, Size: 452, Hash: 0x488b5c2428488918, Ratio: 0.99, Route: true},
{Key: 1234567891, Host: "localhost", Port: 22, Size: 4096, Hash: 0x243048899c24c824, Ratio: 0.20, Route: false},
{Key: 1234567892, Host: "kdc.local", Port: 88, Size: 1984, Hash: 0x000048891c24485c, Ratio: 0.06, Route: false},
{Key: 1234567893, Host: "vhost8.dmz.example.com", Port: 27017, Size: 59741, Hash: 0x5c2408488b9c2489, Ratio: 0.0, Route: true},
}
The following results come from an Apple M1 [iMac].
-------------------------------------------------------------------
Benchmark Time CPU Iterations
-------------------------------------------------------------------
BM_marshal_colfer 9.19 ns 9.19 ns 76055542
BM_unmarshal_colfer 18.0 ns 18.0 ns 39832929
BM_marshal_protobuf 22.9 ns 22.9 ns 30565417
BM_unmarshal_protobuf 40.8 ns 40.8 ns 17051087
BM_marshal_flatbuffers 62.4 ns 62.4 ns 11215612
BM_unmarshal_flatbuffers 6.69 ns 6.69 ns 104713608
flatc version 23.5.26
libprotoc 24.4
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin22.6.0
Thread model: posix
Colfer version 2 preview:
-------------------------------------------------------------------
Benchmark Time CPU Iterations
-------------------------------------------------------------------
BM_marshal_colfer 5.63 ns 5.63 ns 123863114
BM_unmarshal_colfer 13.3 ns 13.3 ns 54924361
BM_marshal_protobuf 22.9 ns 22.9 ns 30643424
BM_unmarshal_protobuf 40.6 ns 40.6 ns 17170288
BM_marshal_flatbuffers 62.3 ns 62.3 ns 11615751
BM_unmarshal_flatbuffers 6.66 ns 6.66 ns 105008926
flatc version 23.5.26
libprotoc 24.4
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: arm64-apple-darwin22.6.0
Thread model: posix
Ran with github.com/gogo/protobuf version 1.3.2, and github.com/google/flatbuffers version 23.3.3.
goos: darwin
goarch: arm64
pkg: github.com/pascaldekloe/colfer/go/bench
BenchmarkMarshal/colfer-8 33934717 35.08 ns/op 48 B/op 1 allocs/op
BenchmarkMarshal/protobuf-8 34227038 34.89 ns/op 52 B/op 1 allocs/op
BenchmarkMarshal/flatbuf-8 3670617 325.6 ns/op 472 B/op 12 allocs/op
BenchmarkUnmarshal/colfer-8 26597144 44.85 ns/op 82 B/op 2 allocs/op
BenchmarkUnmarshal/protobuf-8 19887867 60.01 ns/op 82 B/op 2 allocs/op
BenchmarkUnmarshal/flatbuf-8 18122496 66.11 ns/op 82 B/op 2 allocs/op
BenchmarkMarshalReuse/colfer-8 56420584 20.95 ns/op 0 B/op 0 allocs/op
BenchmarkMarshalReuse/protobuf-8 48963435 24.38 ns/op 0 B/op 0 allocs/op
BenchmarkMarshalReuse/flatbuf-8 11152372 107.8 ns/op 0 B/op 0 allocs/op
BenchmarkUnmarshalReuse/colfer-8 47870032 24.80 ns/op 18 B/op 1 allocs/op
BenchmarkUnmarshalReuse/protobuf-8 29596926 40.33 ns/op 18 B/op 1 allocs/op
BenchmarkUnmarshalReuse/flatbuf-8 25561395 46.85 ns/op 18 B/op 1 allocs/op
PASS
ok github.com/pascaldekloe/colfer/go/bench 16.053s
go version go1.20.2 darwin/arm64
libprotoc 3.21.12
flatc version 23.3.3
Colfer version 2 preview:
goos: darwin
goarch: arm64
pkg: github.com/pascaldekloe/colfer/go/bench/poc
BenchmarkMarshalTo-8 183998360 6.201 ns/op
BenchmarkUnmarshal-8 57666315 18.74 ns/op
20M marshals avg 23ns
20M marshals with buffer reuse avg 17ns
20M unmarshals avg 26ns
java version "20" 2023-03-21
Java(TM) SE Runtime Environment (build 20+36-2344)
Java HotSpot(TM) 64-Bit Server VM (build 20+36-2344, mixed mode, sharing)
marshal Colfer x 855,501 ops/sec ±0.15% (96 runs sampled)
unmarshal Colfer x 427,574 ops/sec ±0.13% (100 runs sampled)
marshal JSON x 551,876 ops/sec ±0.24% (96 runs sampled)
unmarshal JSON x 458,536 ops/sec ±0.21% (95 runs sampled)
Node version: v19.8.1
- @alecthomas's Go serialization benchmarks GitHub
- @eishay's JVM serializers GitHub wiki
- @smallnest's Golang Serializer Benchmark Comparison GitHub