-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperf_test.php
More file actions
60 lines (48 loc) · 1.95 KB
/
Copy pathperf_test.php
File metadata and controls
60 lines (48 loc) · 1.95 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
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/*-------------------------------------------------------+
| DataVaccinator Vault Provider System
| Copyright (C) DataVaccinator
| https://www.datavaccinator.com/
+--------------------------------------------------------+
| Filename: perf_test.php
| Author: Data Vaccinator Development Team
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (count($argv) < 4) {
print("Please provide ProviderID Password URL{:Port} durationSec clients\n");
exit();
}
require_once(__DIR__ . '/util.php'); // include common functions
$serviceProviderID = $argv[1];
$serviceProviderPwd = $argv[2];
$url = $argv[3] . "/index.php";
$duration = getFromHash($argv, 4, 0);
$clients = getFromHash($argv, 5, 0);
if ($duration < 1) { $duration = 10; } // 10 sec default
if ($clients < 1) { $clients = 4; } // 4 clients default
$call = "php perf_client.php $serviceProviderID $serviceProviderPwd $url $duration";
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a pipe that the child will write to
);
$proc = array();
for ($client=0; $client < $clients; $client++) {
print("Start client $client...\n");
exec("$call > output$client.txt &");
}
sleep($duration + 3); // wait 3 extra seconds
for ($client=0; $client < $clients; $client++) {
$t = file_get_contents("output$client.txt");
print($t."\n");
unlink("output$client.txt");
}
print("Done\n");
exit(0);