1
|
<?php
|
2
|
|
3
|
class ModuleTests extends PHPUnit_Framework_TestCase {
|
4
|
|
5
|
function test_load_polytomousKey() {
|
6
|
|
7
|
$polytomousKeysPager = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, $polytomousKeyUuid);
|
8
|
|
9
|
print("\n\n<h4>Benchmarking web services: deep initialization vs. bit-by-bit initialization</h4>\n"
|
10
|
. $polytomousKeysPager->count . " PolytomousKeys to load.\n");
|
11
|
|
12
|
print("<table border=\"1\">\n<tr><th>key uuid</td><td>bit-by-bit initialization</td><td>deep initialization</td></tr>\n");
|
13
|
flush();
|
14
|
|
15
|
$time_load_bbb_total = 0;
|
16
|
$time_load_deep_total = 0;
|
17
|
$i = 0;
|
18
|
foreach ($polytomousKeysPager->records as $polytomousKey) {
|
19
|
|
20
|
if (! is_uuid($polytomousKey->uuid)) {
|
21
|
continue;
|
22
|
}
|
23
|
// if($i++ == 4){
|
24
|
|
25
|
// break;
|
26
|
|
27
|
// }
|
28
|
|
29
|
|
30
|
print("<tr><td>$polytomousKey->uuid</td>");
|
31
|
// ---- bit-by-bit ---- //
|
32
|
|
33
|
$time_load_start = microtime(true);
|
34
|
$polytomousKey = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, $polytomousKey->uuid);
|
35
|
_load_polytomousKeySubGraph($polytomousKey->root);
|
36
|
$time_load = microtime(true) - $time_load_start;
|
37
|
// if($i++ == 1){
|
38
|
|
39
|
// var_dump($polytomousKey);
|
40
|
|
41
|
// }
|
42
|
|
43
|
$time_load_bbb_total += $time_load;
|
44
|
print("<td>" . sprintf('%3.3f', $time_load) . "s</td>");
|
45
|
|
46
|
// ---- deep ---- //
|
47
|
|
48
|
$time_load_start = microtime(true);
|
49
|
$polytomousKey = cdm_ws_get("portal/" . CDM_WS_POLYTOMOUSKEY, array($polytomousKey->uuid, "loadWithNodes"));
|
50
|
$time_load = microtime(true) - $time_load_start;
|
51
|
// if($i++ == 1){
|
52
|
|
53
|
// var_dump($polytomousKey);
|
54
|
|
55
|
// }
|
56
|
|
57
|
$time_load_deep_total += $time_load;
|
58
|
print("<td>" . sprintf('%3.3f', $time_load) . "s</td></tr>\n");
|
59
|
|
60
|
}
|
61
|
print("<tr><td>total time</td><td>" . sprintf('%3.3f', $time_load_bbb_total) . "s</td><td>" . sprintf('%3.3f', $time_load_deep_total) . "s</td></tr>\n");
|
62
|
flush();
|
63
|
|
64
|
}
|
65
|
|
66
|
}
|