@@ -62,27 +62,11 @@ void init_packages() {
62
62
node.set_nodeid (HashUtil::randomString (keyLen));
63
63
node.set_name (HashUtil::randomString (valLen));
64
64
65
- // package.set_virtualpath(HashUtil::randomString(lenString)); //as key
66
- // package.set_isdir(true);
67
- // package.set_opcode();
68
-
69
- // package.set_replicanum(5); //orginal--Note: never let it be nagative!!!
70
-
71
- /*
72
- package.set_realfullpath(
73
- "Some-Real-longer-longer-and-longer-Paths--------");
74
- package.add_listitem("item-----1");
75
- package.add_listitem("item-----2");
76
- package.add_listitem("item-----3");
77
- package.add_listitem("item-----4");
78
- package.add_listitem("item-----5");
79
- package.add_listitem(HashUtil::randomString(8192));
80
- */
81
65
pkgList.push_back (node.SerializeAsString ());
82
66
}
83
67
}
84
68
85
- int benchmarkInsert () {
69
+ int benchmarkAddNode () {
86
70
87
71
double start = 0 ;
88
72
double end = 0 ;
@@ -109,30 +93,95 @@ int benchmarkInsert() {
109
93
end = TimeUtil::getTime_msec ();
110
94
111
95
char buf[200 ];
112
- sprintf (buf, " Inserted packages , %d, %d, cost(ms), %f" , numOfOps - errCount,
96
+ sprintf (buf, " Add Nodes , %d, %d, cost(ms), %f" , numOfOps - errCount,
113
97
numOfOps, end - start);
114
98
cout << buf << endl;
115
99
116
100
return 0 ;
117
101
}
118
102
103
+
104
+ int benchmarkAddNodeEdge () {
105
+
106
+ vector<string> pkgList_append = pkgList;
107
+
108
+ vector<string>::iterator it;
109
+
110
+ double start = 0 ;
111
+ double end = 0 ;
112
+ start = TimeUtil::getTime_msec ();
113
+ int errCount = 0 ;
114
+
115
+ int c = 0 ;
116
+ for (it = pkgList_append.begin (); it != pkgList_append.end (); it++) {
117
+
118
+ c++;
119
+
120
+ string pkg_str = *it;
121
+
122
+ ZHTplusGraph::Node node;
123
+ node.ParseFromString (pkg_str);
124
+
125
+ int ret = zpc.ZHTplusGraphAddNodeEdge (node.nodeid (), node.nodeid (), node.nodeid () + " -" + node.nodeid (), " e" + node.nodeid ());
126
+
127
+ if (ret < 0 ) {
128
+ errCount++;
129
+ }
130
+ }
119
131
132
+ end = TimeUtil::getTime_msec ();
120
133
134
+ char buf[200 ];
135
+ sprintf (buf, " Add NodeEdges, %d, %d, cost(ms), %f" , numOfOps - errCount,
136
+ numOfOps, end - start);
137
+ cout << buf << endl;
121
138
122
- int benchmarkAppend () {
139
+ return 0 ;
140
+ }
141
+
142
+ int benchmarkAddNodeProperty () {
123
143
124
144
vector<string> pkgList_append = pkgList;
125
145
126
146
vector<string>::iterator it;
127
- // for (it = pkgList.begin(); it != pkgList.end(); it++) {
128
147
129
- // ZPack package;
130
- // package.ParseFromString((*it));
148
+ double start = 0 ;
149
+ double end = 0 ;
150
+ start = TimeUtil::getTime_msec ();
151
+ int errCount = 0 ;
152
+
153
+ int c = 0 ;
154
+ for (it = pkgList_append.begin (); it != pkgList_append.end (); it++) {
131
155
132
- // package. add_listitem("item-----6-append") ;
156
+ c++ ;
133
157
134
- // pkgList_append.push_back(package.SerializeAsString());
135
- // }
158
+ string pkg_str = *it;
159
+
160
+ ZHTplusGraph::Node node;
161
+ node.ParseFromString (pkg_str);
162
+
163
+ int ret = zpc.ZHTplusGraphAddNodeProperty (node.nodeid (), node.nodeid () + " -id" , node.nodeid () + " 1" , node.nodeid () + " _val" );
164
+
165
+ if (ret < 0 ) {
166
+ errCount++;
167
+ }
168
+ }
169
+
170
+ end = TimeUtil::getTime_msec ();
171
+
172
+ char buf[200 ];
173
+ sprintf (buf, " Add NodeProperties, %d, %d, cost(ms), %f" , numOfOps - errCount,
174
+ numOfOps, end - start);
175
+ cout << buf << endl;
176
+
177
+ return 0 ;
178
+ }
179
+
180
+ int benchmarkAddNodeEdgeProperty () {
181
+
182
+ vector<string> pkgList_append = pkgList;
183
+
184
+ vector<string>::iterator it;
136
185
137
186
double start = 0 ;
138
187
double end = 0 ;
@@ -149,8 +198,7 @@ int benchmarkAppend() {
149
198
ZHTplusGraph::Node node;
150
199
node.ParseFromString (pkg_str);
151
200
152
- int ret = zpc.ZHTplusGraphAddNodeEdge (node.nodeid (), node.nodeid (), node.nodeid () + " -" + node.nodeid (), " e" + node.nodeid ());
153
- ret = zpc.ZHTplusGraphAddNodeEdgeProperty (node.nodeid (), node.nodeid () + " -" + node.nodeid (), node.nodeid () + " 1" , node.nodeid () + " 1" , node.nodeid () + " _val" );
201
+ int ret = zpc.ZHTplusGraphAddNodeEdgeProperty (node.nodeid (), node.nodeid () + " -" + node.nodeid (), node.nodeid () + " 1" , node.nodeid () + " 1" , node.nodeid () + " _val" );
154
202
155
203
if (ret < 0 ) {
156
204
errCount++;
@@ -160,14 +208,46 @@ int benchmarkAppend() {
160
208
end = TimeUtil::getTime_msec ();
161
209
162
210
char buf[200 ];
163
- sprintf (buf, " Appended packages , %d, %d, cost(ms), %f" , numOfOps - errCount,
211
+ sprintf (buf, " Add NodeEdgeProperties , %d, %d, cost(ms), %f" , numOfOps - errCount,
164
212
numOfOps, end - start);
165
213
cout << buf << endl;
166
214
167
215
return 0 ;
168
- }
216
+ }
217
+
218
+ float benchmarkLookupNodeProperty () {
169
219
170
- float benchmarkLookup () {
220
+ double start = 0 ;
221
+ double end = 0 ;
222
+ start = TimeUtil::getTime_msec ();
223
+ int errCount = 0 ;
224
+
225
+ int c = 0 ;
226
+ vector<string>::iterator it;
227
+ for (it = pkgList.begin (); it != pkgList.end (); it++) {
228
+
229
+ string result;
230
+ c++;
231
+
232
+ string pkg_str = *it;
233
+ ZHTplusGraph::Node node;
234
+
235
+ node.ParseFromString (pkg_str);
236
+
237
+ string propertyValue = zpc.ZHTplusGraphGetNodePropertyValue (node.nodeid (), node.nodeid () + " -id" );
238
+ }
239
+
240
+ end = TimeUtil::getTime_msec ();
241
+
242
+ char buf[200 ];
243
+ sprintf (buf, " Lookup NodeProperties, %d, %d, cost(ms), %f" , numOfOps - errCount,
244
+ numOfOps, end - start);
245
+ cout << buf << endl;
246
+
247
+ return 0 ;
248
+ }
249
+
250
+ float benchmarkLookupNodeEdgeProperty () {
171
251
172
252
double start = 0 ;
173
253
double end = 0 ;
@@ -186,21 +266,14 @@ float benchmarkLookup() {
186
266
187
267
node.ParseFromString (pkg_str);
188
268
189
- string propertyValue = zpc.ZHTplusGraphGetNodeEdgePropertyValue (node.nodeid (), node.nodeid () + " -" + node.nodeid (), node.nodeid () + " 1" );
190
-
191
- // cout << "Found result: "<< result << endl;
192
- // if (ret < 0) {
193
- // errCount++;
194
- // } else if (result.empty()) { //empty string
195
- // errCount++;
196
- // }
269
+ string propertyValue = zpc.ZHTplusGraphGetNodeEdgePropertyValue (node.nodeid (), node.nodeid () + " -" + node.nodeid (), node.nodeid () + " 1" );
197
270
}
198
271
199
272
end = TimeUtil::getTime_msec ();
200
273
201
274
char buf[200 ];
202
- sprintf (buf, " Lookuped packages , %d, %d, cost(ms), %f" , numOfOps - errCount,
203
- numOfOps, end - start);
275
+ sprintf (buf, " Lookup NodeEdgeProperties , %d, %d, cost(ms), %f" , numOfOps - errCount,
276
+ numOfOps, end - start);
204
277
cout << buf << endl;
205
278
206
279
return 0 ;
@@ -255,13 +328,17 @@ int benchmark(string &zhtConf, string &neighborConf) {
255
328
256
329
init_packages ();
257
330
258
- benchmarkInsert ();
331
+ benchmarkAddNode ();
259
332
260
- benchmarkAppend ();
261
-
262
- benchmarkLookup ();
333
+ benchmarkAddNodeEdge ();
334
+
335
+ benchmarkAddNodeProperty ();
263
336
264
- // benchmarkRemove();
337
+ benchmarkAddNodeEdgeProperty ();
338
+
339
+ benchmarkLookupNodeProperty ();
340
+
341
+ benchmarkLookupNodeEdgeProperty ();
265
342
266
343
zpc.teardown ();
267
344
0 commit comments