MCPcopy Index your code
hub / github.com/techfort/LokiJS / initializeDatabaseBatch

Function initializeDatabaseBatch

benchmark/benchmark_binary.js:110–152  ·  view source on GitHub ↗
(silent, docCount)

Source from the content-addressed store, hash-verified

108// silent : if true we wont log timing info to console
109// docCount : number of random documents to generate collection with
110function initializeDatabaseBatch(silent, docCount) {
111 var start, end, totalTime;
112 var totalTimes = [];
113 var totalMS = 0.0;
114 var batch = [];
115
116 if (typeof docCount === "undefined") {
117 docCount = 5000;
118 }
119
120 arraySize = docCount;
121
122 for (var idx = 0; idx < arraySize; idx++) {
123 var v1 = genRandomVal();
124 var v2 = genRandomVal();
125
126 batch.push({
127 customId: idx,
128 val: v1,
129 val2: v2,
130 val3: "more data 1234567890"
131 });
132 }
133
134 start = process.hrtime();
135 samplecoll.insert(batch);
136 end = process.hrtime(start);
137 totalTimes.push(end);
138
139 if (silent === true) {
140 return;
141 }
142
143 for (var idx = 0; idx < totalTimes.length; idx++) {
144 totalMS += totalTimes[idx][0] * 1e3 + totalTimes[idx][1] / 1e6;
145 }
146
147 //var totalMS = end[0] * 1e3 + end[1]/1e6;
148 totalMS = totalMS.toFixed(2);
149 var rate = arraySize* 1000 / totalMS;
150 rate = rate.toFixed(2);
151 console.log("load (batch insert) : " + totalMS + "ms (" + rate + ") ops/s (" + arraySize + " documents)");
152}
153
154function perfFind(multiplier) {
155 var start, end;

Callers 1

Calls 1

genRandomValFunction · 0.70

Tested by

no test coverage detected