-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
util_test.php
57 lines (45 loc) · 1.54 KB
/
util_test.php
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
<?php
// Copyright 2022 The Ip2Region Authors. All rights reserved.
// Use of this source code is governed by a Apache2.0-style
// license that can be found in the LICENSE file.
//
// @Author Lion <[email protected]>
// @Date 2022/06/22
require dirname(__FILE__) . '/XdbSearcher.class.php';
function testLoadHeader() {
$header = XdbSearcher::loadHeaderFromFile('../../data/ip2region.xdb');
if ($header == null) {
printf("failed to load header from file\n");
return;
}
printf("header loaded: ");
print_r($header);
}
function testLoadVectorIndex() {
$vIndex = XdbSearcher::loadVectorIndexFromFile('../../data/ip2region.xdb');
if ($vIndex == null) {
printf("failed to load vector index from file\n");
return;
}
printf("vector index loaded: length=%d\n", strlen($vIndex));
}
function testLoadContent() {
$cBuff = XdbSearcher::loadContentFromFile('../../data/ip2region.xdb');
if ($cBuff == null) {
printf("failed to load content from file\n");
return;
}
printf("content loaded, length=%d\n", strlen($cBuff));
}
printf("testing loadHeader ... \n");
$now = XdbSearcher::now();
testLoadHeader();
printf("done, cost: %0.5f ms\n\n", XdbSearcher::now() - $now);
printf("testing loadVectorIndex ... \n");
$now = XdbSearcher::now();
testLoadVectorIndex();
printf("done, cost: %0.5f ms\n\n", XdbSearcher::now() - $now);
printf("testing loadContent ... \n");
$now = XdbSearcher::now();
testLoadContent();
printf("done, cost: %0.5f ms\n\n", XdbSearcher::now() - $now);