-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot.d
More file actions
54 lines (46 loc) · 1.2 KB
/
plot.d
File metadata and controls
54 lines (46 loc) · 1.2 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
module plot;
import std.process;
import std.string;
import std.stdio: writeln;
import std.file;
class ExitException : Exception
{
int status;
@safe pure nothrow this(int status, string file = __FILE__, size_t line = __LINE__)
{
super(null, file, line);
this.status = status;
}
}
string run(string cmd)
{
auto x = executeShell(cmd);
if (x.status != 0)
{
throw new ExitException(x.status);
}
return x.output;
}
int main(string[] args)
{
try
{
immutable os = run(`uname -o`).replace("\n", "");
immutable processor = run(`cat /proc/cpuinfo | grep -m 1 "model name"`).replace("model name\t: ", "").replace("\n","");
immutable title = os ~ ", " ~ processor;
run(`gnuplot -persist <<EOF
set title"` ~ title ~ `"
set autoscale
set logscale x 2
set xlabel 'size in bytes'
set ylabel 'GB/s'
set terminal qt size 900,480
plot '` ~ args[1] ~ `' using "size(bytes)":"memcpyC(GB/s)" with lines, '' using "size(bytes)":"memcpyD(GB/s)" with lines
`);
}
catch(ExitException e)
{
return e.status;
}
return 0;
}