blob: 8dd1df9c9a692ee9a245835bbc21371cd153bf93 (
plain)
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
61
62
63
64
65
|
#!/bin/sh
set -eu
die()
{
echo "$@" 1>&2
exit 1
}
gotcmd()
{
command -v "$1" > /dev/null || die "Need command $1"
}
gotfile()
{
test -e "$1" || die "Need file $1"
}
cpubench_xz()
{
local filename
local size
size=1G
filename="$(mktemp)"
truncate -s 10G "$filename"
echo "CPU benchmark (xz on a $size sparse file)"
/bin/time --format="%e" xz -T0 < "$filename" > /dev/null
rm -f "$filename"
}
network_localhost()
{
local filename
local port
local size
filename="$(mktemp)"
port=3858
size=10G
truncate -s "$size" "$filename"
echo "Network benchmark (netcat a $size sparse file across localhost)"
nc -l localhost "$port" > /dev/null &
/bin/time --format="%e" nc -N localhost "$port" < "$filename"
rm -f "$filename"
}
for bench in "$@"
do
case "$bench" in
cpu)
cpubench_xz
;;
network-localhost)
netbench_localhost
;;
*)
die "unknown benchmark type $bench"
;;
esac
done
|