2 * Copyright (c) 2008 Novell, Inc. (http://www.novell.com)
5 * Moonlight List (moonlight-list@lists.ximian.com)
7 * Permission is hereby granted, free of charge, to any person
8 * obtaining a copy of this software and associated documentation
9 * files (the "Software"), to deal in the Software without
10 * restriction, including without limitation the rights to use,
11 * copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 * OTHER DEALINGS IN THE SOFTWARE.
33 using System
.Diagnostics
;
35 namespace PerfSuiteRunner
{
37 public class DrtItem
{
39 public int StartTime
= 0;
40 public int EndTime
= 5000;
41 public int Interval
= 40;
42 public int Timeout
= 35000;
44 public int Width
= 400;
45 public int Height
= 400;
46 public string InputFile
= String
.Empty
;
47 public string UniqueId
= String
.Empty
;
48 public string Name
= String
.Empty
;
50 public static string ItemsDirectory
= "perf-suite-set";
52 public string FullFileName
{
54 return String
.Format ("{0}/{1}", ItemsDirectory
, InputFile
);
59 public DrtItem (XmlNode node
)
61 if (node
.Attributes
["startTime"] != null)
62 StartTime
= Convert
.ToInt32 (node
.Attributes
["startTime"].Value
);
64 if (node
.Attributes
["endTime"] != null)
65 EndTime
= Convert
.ToInt32 (node
.Attributes
["endTime"].Value
);
67 if (node
.Attributes
["interval"] != null)
68 Interval
= Convert
.ToInt32 (node
.Attributes
["interval"].Value
);
70 if (node
.Attributes
["inputFile"] != null)
71 InputFile
= node
.Attributes
["inputFile"].Value
;
73 if (node
.Attributes
["uniqueId"] != null)
74 UniqueId
= node
.Attributes
["uniqueId"].Value
;
76 if (node
.Attributes
["name"] != null)
77 Name
= node
.Attributes
["name"].Value
;
79 if (node
.Attributes
["timeout"] != null)
80 Timeout
= Convert
.ToInt32 (node
.Attributes
["timeout"].Value
);
82 if (node
.Attributes
["runs"] != null)
83 Runs
= Convert
.ToInt32 (node
.Attributes
["runs"].Value
);
85 if (node
.Attributes
["width"] != null)
86 Width
= Convert
.ToInt32 (node
.Attributes
["width"].Value
);
88 if (node
.Attributes
["height"] != null)
89 Height
= Convert
.ToInt32 (node
.Attributes
["height"].Value
);
92 public bool IsValid ()
100 if (EndTime
< StartTime
)
103 if (InputFile
== String
.Empty
)
106 if (UniqueId
== String
.Empty
)
112 if (Name
== String
.Empty
)
118 if (Width
< 1 || Height
< 1)
127 public DrtResult
Run ()
129 DrtResult result
= null;
130 Process proc
= new Process ();
133 string tmpFileName
= Path
.GetTempFileName ();
135 string arguments
= String
.Format ("-f \"{0}\" -s \"{1}\" -e \"{2}\" -i \"{3}\" -n \"{4}\" -r \"{5}\" -t \"{6}\" -w \"{7}\" -h \"{8}\"",
146 proc
.EnableRaisingEvents
= false;
147 proc
.StartInfo
.FileName
= "perf-tool";
148 proc
.StartInfo
.Arguments
= arguments
;
152 if (proc
.ExitCode
== 0)
153 result
= new DrtResult (tmpFileName
);
164 public override string ToString ()
166 return String
.Format ("{0} - {1}", UniqueId
, Name
);