-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert.cpp
More file actions
66 lines (52 loc) · 1.19 KB
/
insert.cpp
File metadata and controls
66 lines (52 loc) · 1.19 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
#include<bits/stdc++.h>
#include"kvStore.cpp"
using namespace std;
kvStore kv(10000000);
string letters , letters1;
Slice *random_key(){
Slice *ret = new Slice;
ret->size = 64;
ret->data = (char *)malloc(64*sizeof(char));
for(int i=0;i<64;i++)
ret->data[i] = letters[rand()%52];
return ret;
}
Slice *random_value(){
Slice *ret = new Slice;
ret->size = 255;
ret->data = (char *)malloc(255*sizeof(char));
for(int i=0;i<255;i++)
ret->data[i] = letters1[rand()%96];
return ret;
}
pair <Slice *,Slice *> arr[10000000];
void checktime()
{
struct timespec ts;
printf("Running Program\n");
clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
long double st=ts.tv_nsec/(1e9)+ts.tv_sec;
for(int i=0;i<1e7;i++)
{
kv.put(*arr[i].first,*arr[i].first);
}
clock_gettime(CLOCK_MONOTONIC_RAW,&ts);
long double en=ts.tv_nsec/(1e9)+ts.tv_sec;
printf("Program ended\nTime = %Lf\n",en-st);
}
int main(void)
{
letters = "";
for(char i = 'a';i<='z';i++)letters+=i;
for(char i = 'A';i<='Z';i++)letters+=i;
letters1 = "";
for(int i = 32;i<=127;i++)letters1+=char(i);
for(int i=0;i<1e7;i++)
{
arr[i].first = random_key();
arr[i].second = random_value();
}
cout<<"Done Making\n";
checktime();
return 0;
}