MCPcopy Create free account
hub / github.com/apache/fory / buildResults

Function buildResults

benchmarks/javascript/benchmark.js:984–1023  ·  view source on GitHub ↗
(datasets, options)

Source from the content-addressed store, hash-verified

982}
983
984function buildResults(datasets, options) {
985 const benchmarks = [];
986
987 for (const dataset of datasets) {
988 if (options.data && options.data !== dataset.key) {
989 continue;
990 }
991 for (const serializerName of SERIALIZER_ORDER) {
992 if (options.serializer && options.serializer !== serializerName) {
993 continue;
994 }
995 for (const operation of ["Serialize", "Deserialize"]) {
996 const benchName = `BM_${serializerName[0].toUpperCase()}${serializerName.slice(1)}_${dataset.label}_${operation}`;
997 const fn = createBenchmarkCase(serializerName, dataset, operation);
998 const realTimeNs = benchmark(fn, options.durationSeconds);
999 benchmarks.push({
1000 name: benchName,
1001 real_time: realTimeNs,
1002 cpu_time: realTimeNs,
1003 time_unit: "ns",
1004 });
1005 console.log(`${benchName}: ${realTimeNs.toFixed(1)} ns/op`);
1006 }
1007 }
1008 }
1009
1010 const sizeCounters = {
1011 name: "BM_PrintSerializedSizes",
1012 };
1013 const sizeSerializers = options.schemaMismatch ? ["fory"] : SERIALIZER_ORDER;
1014 for (const dataset of datasets) {
1015 const value = dataset.createValue();
1016 for (const serializerName of sizeSerializers) {
1017 const bytes = serializeBytes(serializerName, dataset, value);
1018 sizeCounters[`${serializerName}_${dataset.sizeKey}_size`] = bytes.length;
1019 }
1020 }
1021 benchmarks.push(sizeCounters);
1022 return benchmarks;
1023}
1024
1025function main() {
1026 const options = parseArgs(process.argv.slice(2));

Callers 1

mainFunction · 0.85

Calls 5

createBenchmarkCaseFunction · 0.85
benchmarkFunction · 0.85
serializeBytesFunction · 0.85
logMethod · 0.80
sliceMethod · 0.45

Tested by

no test coverage detected