- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspeed3.js
More file actions
Latest commit
89 lines (68 loc) · 2.43 KB
/
Copy pathspeed3.js
File metadata and controls
89 lines (68 loc) · 2.43 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
varcount=0;
varidx;
vartxn;
varstart=newDate();
vardb,dbname;
for(dbnameincatalog.db)
db=newDb(dbname),db.drop();
db=newDb("tstdb",{onDisk:true});
varstore=db.createDocStore("collection",{onDisk:true});
varindex=store.createIndex("speedIdx",{onDisk:true,idxType:0},{doc:"fwd:dbl"});
while(count<1000){
varid,cnt;
idx=0;
vardocIds=[];
// txn = jsdb_beginTxn();
vararray=[],key;
while(idx<1000){
// print ("batch: ", count, " item: ", idx);
array[idx]={
doc : Math.random()*(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;
}
docIds=store.writeDocs(array);
varnxt;
for(idx=0;idx<1000;idx++){
// keys = index.buildKey(docIds[idx], array[idx].doc);
// for( nxt = 0; nxt < keys.length; nxt++ )
key=index.insertKey(docIds[idx],array[idx].doc);
}
print("key: [",key,"] docId: ",docIds[idx-1]);
// jsdb_commitTxn();
count+=1;
// print ("batch: ", count);
}
varstop=newDate();
varins=(stop-start)/1000.;
start=stop;
varcursor,doc;
cursor=index.createCursor();
varreccnt=0;
varprev=0;
vardocId;
while(docId=cursor.move(CursorOp.opNext)){
key=cursor.keyAt();
if(!(reccnt%2500))
print("docId: ",docId,"\tkey: [",key,"]");
if(key<prev)
print("out of order record #",reccnt," docId: ",doc.docId,"\tkey: ",key," prev: ",prev);
prev=key;
reccnt+=1;
}
varstop=newDate();
print("insert: ",ins," seconds");
print("found: ",reccnt," should be 1000000");
print("sort verify: ",(stop-start)/1000.," seconds");