-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspeed1.js
72 lines (56 loc) · 1.95 KB
/
speed1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
var count = 0;
var idx;
var txn;
var start = new Date();
var db, dbname;
for (dbname in catalog.db)
db = new Db(dbname), db.drop();
db = new Db("tstdb", {onDisk:true});
var store = db.createDocStore("collection", {onDisk:true});
while(count<1000) {
var id, cnt;
idx = 0;
// txn = jsdb_beginTxn();
var array = [];
while(idx<1000) {
array[idx] = {
doc : count * 1000 + idx,
cnt : count,
idx : idx,
/* text0 : "This is a test string designed to make this record bigger0",
text1 : "This is a test string designed to make this record bigger1",
text2 : "This is a test string designed to make this record bigger2",
text3 : "This is a test string designed to make this record bigger3",
text4 : "This is a test string designed to make this record bigger4",
text5 : "This is a test string designed to make this record bigger5",
text6 : "This is a test string designed to make this record bigger6",
text7 : "This is a test string designed to make this record bigger7",
text8 : "This is a test string designed to make this record bigger8",
text9 : "This is a test string designed to make this record bigger9"
*/ };
idx += 1;
}
// print ("batch: ", count, " item: ", idx);
store.writeDocs(array);
// jsdb_commitTxn();
count += 1;
// print ("batch: ", count);
}
var stop = new Date();
var ins = (stop - start) / 1000.;
start = stop;
var iterator, doc;
iterator = store.createIterator();
iterator.seek(IteratorOp.opBegin);
var reccnt = 0, docId;
while(docId = iterator.next()) {
doc = docId.retrieve();
if (!(reccnt % 998)) {
print("idx: ", reccnt, " docId: ", doc.docId, " doc.doc: ", doc.doc);
}
reccnt += 1;
}
var stop = new Date();
print ("found: ", reccnt, " should be 1000000");
print ("insert: ", ins, " seconds");
print ("scan verify: ", (stop - start) / 1000., " seconds");