blob: 3d8c1eeb5b2e69ee96c18dd9f16cca17ca4b0b49 (
plain) (
blame)
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
66
67
68
69
70
|
/*******************************************************************************
* Copyright (c) 2013 Red Hat Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.internal.perf;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* This class handles the execution of the perf stat command
* and stores the resulting data.
*/
public class StatData extends AbstractDataManipulator {
private String prog;
private String [] args;
private int runCount;
private String [] events;
public StatData(String title, File workDir, String prog, String [] args, int runCount, String[] events) {
super(title, workDir);
this.prog = prog;
this.args = args;
this.runCount = runCount;
this.events = events;
}
@Override
public void parse() {
String [] cmd = getCommand(this.prog, this.args);
// perf stat prints the data to standard error
performCommand(cmd, 2);
}
protected String [] getCommand(String prog, String [] args) {
List<String> ret = new ArrayList<String>(Arrays.asList(
new String[] {"perf", "stat" })); //$NON-NLS-1$ //$NON-NLS-2$
if (runCount > 1) {
ret.add("-r"); //$NON-NLS-1$
ret.add(String.valueOf(runCount));
}
if (events != null) {
for (String event : events) {
ret.add("-e"); //$NON-NLS-1$
ret.add(event);
}
}
ret.add(prog);
ret.addAll(Arrays.asList(args));
return ret.toArray(new String [0]);
}
protected String getProgram () {
return prog;
}
protected String [] getArguments () {
return args;
}
}
|