-
Notifications
You must be signed in to change notification settings - Fork 4
/
swoole_table.php
28 lines (22 loc) · 744 Bytes
/
swoole_table.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
<?php
// https://github.com/swoole/swoole-src
// pecl install swoole
$start = time();
$visits = new swoole_table(11000000);
$visits->column('user', swoole_table::TYPE_INT);
$visits->column('mark', swoole_table::TYPE_INT);
$visits->column('location', swoole_table::TYPE_INT);
$visits->column('visited_at', swoole_table::TYPE_INT);
$visits->create();
$i = 1;
while ($visitsData = @file_get_contents("data/visits_$i.json")) {
$visitsData = json_decode($visitsData, true);
foreach ($visitsData['visits'] as $k => $row) {
$visits->set($row['id'], $row);
}
$i++;
}
unset($visitsData);
gc_collect_cycles();
echo 'init time: ' . (time() - $start) . ', memory: ' . intval(memory_get_usage() / 1000000) . "\n";
sleep(3600);