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\nBenchmarking web services: deep initialization vs. bit-by-bit initialization\n"
|
10
|
. $polytomousKeysPager->count . " PolytomousKeys to load.\n");
|
11
|
|
12
|
print("1) bit-by-bit initialization ...\n");
|
13
|
flush();
|
14
|
$time_load_total = 0;
|
15
|
$i = 0;
|
16
|
foreach($polytomousKeysPager->records as $polytomousKey){
|
17
|
if(! is_uuid($polytomousKey->uuid)){
|
18
|
continue;
|
19
|
}
|
20
|
$time_load_start = microtime(true);
|
21
|
$polytomousKey = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, $polytomousKey->uuid);
|
22
|
_load_polytomousKeySubGraph($polytomousKey->root);
|
23
|
$time_load = microtime(true) - $time_load_start;
|
24
|
print($polytomousKey->uuid . " :\t" . sprintf('%3.3f', $time_load). "s\n");
|
25
|
if($i++ == 1){
|
26
|
var_dump($polytomousKey);
|
27
|
}
|
28
|
$time_load_total += $time_load;
|
29
|
}
|
30
|
flush();
|
31
|
print("total time = " . sprintf('%3.3f', $time_load_total) . "s\n");
|
32
|
|
33
|
|
34
|
print("\n2) deep initialization ...\n");
|
35
|
flush();
|
36
|
$time_load_total = 0;
|
37
|
$i = 0;
|
38
|
foreach($polytomousKeysPager->records as $polytomousKey){
|
39
|
if(! is_uuid($polytomousKey->uuid)){
|
40
|
continue;
|
41
|
}
|
42
|
$time_load_start = microtime(true);
|
43
|
$polytomousKey = cdm_ws_get("portal/" . CDM_WS_POLYTOMOUSKEY, array($polytomousKey->uuid, "loadWithNodes"));
|
44
|
$time_load = microtime(true) - $time_load_start;
|
45
|
print($polytomousKey->uuid . " :\t" . sprintf('%3.3f', $time_load). "s\n");
|
46
|
if($i++ == 1){
|
47
|
var_dump($polytomousKey);
|
48
|
}
|
49
|
$time_load_total += $time_load;
|
50
|
}
|
51
|
print("total time = " . sprintf('%3.3f', $time_load_total) . "s\n");
|
52
|
flush();
|
53
|
|
54
|
}
|
55
|
|
56
|
}
|