forked from db-benchmarks/db-benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest
More file actions
executable file
·47 lines (40 loc) · 1.31 KB
/
test
File metadata and controls
executable file
·47 lines (40 loc) · 1.31 KB
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
#!/usr/bin/env php
<?php
/* Copyright (C) 2022 Manticore Software Ltd
* You may use, distribute and modify this code under the
* terms of the AGPLv3 license.
*
* You can find a copy of the AGPLv3 license here
* https://www.gnu.org/licenses/agpl-3.0.txt
*/
$cwd = getcwd();
require_once('core/helpers.php');
require_once('core/engine.php');
require_once('core/EsCompatible.php');
$files = glob(__DIR__ . '/plugins/*.php');
foreach ($files as $file) require($file);
engine::init($cwd);
engine::parseCommandLineArguments();
engine::sanitize();
// Acquire lock
$lockFile = '/tmp/db_benchmarks.lock';
if (file_exists($lockFile)) {
$lockPid = trim(file_get_contents($lockFile));
if ($lockPid && posix_kill($lockPid, 0)) {
die("Lock file $lockFile exists and process $lockPid is running. Another benchmark process may be running.\n");
} else {
unlink($lockFile); // Remove stale lock
}
}
touch($lockFile);
// Write current PID to lock file
file_put_contents($lockFile, getmypid());
// Release lock at end
register_shutdown_function(function() use ($lockFile) {
if (file_exists($lockFile)) {
unlink($lockFile);
}
});
if (engine::$mode == 'save') {
$results = engine::saveResultsFromPath(engine::$commandLineArguments['save']);
} else if (engine::$mode == 'test') engine::test($cwd);