v.io/v23/vom/internal: Vom benchmarks. No new functionality.
(This is the second part of the CL, needed to check in the javascript form
of the compiled VDL. :-( )
This CL adds benchmarks for vom, which marshal and unmarhsal an arbitrarily-chosen
"customer record" struct, with a few strings and integers in it.
The test measures the number of allocations and time used for:
- encoding vs decoding
- using vom.Encode/vom.Decode vs vom.Encoder.Encode/vom.Decoder.Decode
- processing a single customer record vs a thousand
- vom vs gob
The comments at the top of the source give comparisons with C++ and Go
protocol buffers.
Typical output (including CL 14185):
$ v23 go test -bench . v.io/v23/vom/internal
Allocations per vom.Encode : 572
Allocations per vom.Decode : 405
Allocations per vom.Encoder.Encode (1 Customer) : 572
Allocations per vom.Encoder.Encode (1000 Customers): 74509
Allocations per vom.Decoder.Decode (1 Customer) : 4469
Allocations per vom.Decoder.Decode (1000 Customers): 405068
Allocations per gob.Encoder.Encode (1 Customer) : 53
Allocations per gob.Encoder.Encode (1000 Customers): 3073
Allocations per gob.Decoder.Decode (1 Customer) : 523
Allocations per gob.Decoder.Decode (1000 Customers): 14512
PASS
BenchmarkVomEncodeCustomer 10000 149089 ns/op
BenchmarkVomDecodeCustomer 20000 95148 ns/op
BenchmarkVomEncoder1Customer 10000 150061 ns/op
BenchmarkVomEncoder1000Customer 100 18691021 ns/op
BenchmarkVomDecoder1Customer 2000 997658 ns/op
BenchmarkVomDecoder1000Customer 20 85232430 ns/op
BenchmarkGobEncoder1Customer 50000 30675 ns/op
BenchmarkGobEncoder1000Customer 300 4227359 ns/op
BenchmarkGobDecoder1Customer 10000 111041 ns/op
BenchmarkGobDecoder1000Customer 500 3621498 ns/op
ok v.io/v23/vom/internal 19.863s
$
Without CL 14185, the vom/Decode lines are different:
Allocations per vom.Decode : 4469
BenchmarkVomDecodeCustomer 2000 1007225 ns/op
MultiPart: 2/2
Change-Id: I47f2422e73fb0e22e0a5eec6fc038d1031517b16
diff --git a/src/gen-vdl/v.io/v23/vom/internal/index.js b/src/gen-vdl/v.io/v23/vom/internal/index.js
new file mode 100644
index 0000000..9028ae1
--- /dev/null
+++ b/src/gen-vdl/v.io/v23/vom/internal/index.js
@@ -0,0 +1,97 @@
+// Copyright 2015 The Vanadium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// This file was auto-generated by the vanadium vdl tool.
+var vdl = require('../../../../../vdl');
+var canonicalize = require('../../../../../vdl/canonicalize');
+
+
+
+
+
+
+module.exports = {};
+
+
+
+// Types:
+var _typeAddressInfo = new vdl.Type();
+var _typeAgencyReport = new vdl.Type();
+var _typeCreditAgency = new vdl.Type();
+var _typeCreditReport = new vdl.Type();
+var _typeCustomer = new vdl.Type();
+var _typeEquifaxCreditReport = new vdl.Type();
+var _typeExperianCreditReport = new vdl.Type();
+var _typeExperianRating = new vdl.Type();
+var _typeTransUnionCreditReport = new vdl.Type();
+_typeAddressInfo.kind = vdl.kind.STRUCT;
+_typeAddressInfo.name = "v.io/v23/vom/internal.AddressInfo";
+_typeAddressInfo.fields = [{name: "Street", type: vdl.types.STRING}, {name: "City", type: vdl.types.STRING}, {name: "State", type: vdl.types.STRING}, {name: "Zip", type: vdl.types.STRING}];
+_typeAgencyReport.kind = vdl.kind.UNION;
+_typeAgencyReport.name = "v.io/v23/vom/internal.AgencyReport";
+_typeAgencyReport.fields = [{name: "EquifaxReport", type: _typeEquifaxCreditReport}, {name: "ExperianReport", type: _typeExperianCreditReport}, {name: "TransUnionReport", type: _typeTransUnionCreditReport}];
+_typeCreditAgency.kind = vdl.kind.ENUM;
+_typeCreditAgency.name = "v.io/v23/vom/internal.CreditAgency";
+_typeCreditAgency.labels = ["Equifax", "Experian", "TransUnion"];
+_typeCreditReport.kind = vdl.kind.STRUCT;
+_typeCreditReport.name = "v.io/v23/vom/internal.CreditReport";
+_typeCreditReport.fields = [{name: "Agency", type: _typeCreditAgency}, {name: "Report", type: _typeAgencyReport}];
+_typeCustomer.kind = vdl.kind.STRUCT;
+_typeCustomer.name = "v.io/v23/vom/internal.Customer";
+_typeCustomer.fields = [{name: "Name", type: vdl.types.STRING}, {name: "Id", type: vdl.types.INT64}, {name: "Active", type: vdl.types.BOOL}, {name: "Address", type: _typeAddressInfo}, {name: "Credit", type: _typeCreditReport}];
+_typeEquifaxCreditReport.kind = vdl.kind.STRUCT;
+_typeEquifaxCreditReport.name = "v.io/v23/vom/internal.EquifaxCreditReport";
+_typeEquifaxCreditReport.fields = [{name: "Rating", type: vdl.types.BYTE}];
+_typeExperianCreditReport.kind = vdl.kind.STRUCT;
+_typeExperianCreditReport.name = "v.io/v23/vom/internal.ExperianCreditReport";
+_typeExperianCreditReport.fields = [{name: "Rating", type: _typeExperianRating}];
+_typeExperianRating.kind = vdl.kind.ENUM;
+_typeExperianRating.name = "v.io/v23/vom/internal.ExperianRating";
+_typeExperianRating.labels = ["Good", "Bad"];
+_typeTransUnionCreditReport.kind = vdl.kind.STRUCT;
+_typeTransUnionCreditReport.name = "v.io/v23/vom/internal.TransUnionCreditReport";
+_typeTransUnionCreditReport.fields = [{name: "Rating", type: vdl.types.INT16}];
+_typeAddressInfo.freeze();
+_typeAgencyReport.freeze();
+_typeCreditAgency.freeze();
+_typeCreditReport.freeze();
+_typeCustomer.freeze();
+_typeEquifaxCreditReport.freeze();
+_typeExperianCreditReport.freeze();
+_typeExperianRating.freeze();
+_typeTransUnionCreditReport.freeze();
+module.exports.AddressInfo = (vdl.registry.lookupOrCreateConstructor(_typeAddressInfo));
+module.exports.AgencyReport = (vdl.registry.lookupOrCreateConstructor(_typeAgencyReport));
+module.exports.CreditAgency = {
+ EQUIFAX: canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeCreditAgency))('Equifax', true), _typeCreditAgency),
+ EXPERIAN: canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeCreditAgency))('Experian', true), _typeCreditAgency),
+ TRANS_UNION: canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeCreditAgency))('TransUnion', true), _typeCreditAgency),
+};
+module.exports.CreditReport = (vdl.registry.lookupOrCreateConstructor(_typeCreditReport));
+module.exports.Customer = (vdl.registry.lookupOrCreateConstructor(_typeCustomer));
+module.exports.EquifaxCreditReport = (vdl.registry.lookupOrCreateConstructor(_typeEquifaxCreditReport));
+module.exports.ExperianCreditReport = (vdl.registry.lookupOrCreateConstructor(_typeExperianCreditReport));
+module.exports.ExperianRating = {
+ GOOD: canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeExperianRating))('Good', true), _typeExperianRating),
+ BAD: canonicalize.reduce(new (vdl.registry.lookupOrCreateConstructor(_typeExperianRating))('Bad', true), _typeExperianRating),
+};
+module.exports.TransUnionCreditReport = (vdl.registry.lookupOrCreateConstructor(_typeTransUnionCreditReport));
+
+
+
+
+// Consts:
+
+
+
+// Errors:
+
+
+
+// Services:
+
+
+
+
+