AndroidAgent.MainActivity.RunBenchmark C# (CSharp) Method

RunBenchmark() static private method

static private RunBenchmark ( long runSetId, string benchmarkName, string machineName, string architecture, string configName ) : void
runSetId long
benchmarkName string
machineName string
architecture string
configName string
return void
		void RunBenchmark (long runSetId, string benchmarkName, string machineName, string architecture, string configName)
		{
			const int DRY_RUNS = 3;
			const int ITERATIONS = 10;
			bool cheat = configName.Equals ("cheat");
			models.RunSet runSet = null;

			if (cheat) {
				runSetId = 1;
			}

			if (!cheat) {
				Logging.GetLogging ().InfoFormat ("Benchmarker | hostname \"{0}\" architecture \"{1}\"" ,machineName ,architecture);
				Logging.GetLogging ().InfoFormat ("Benchmarker | configname \"{0}\"" ,"default");

				models.Commit mainCommit = DetermineCommit ();
				models.Machine machine = new models.Machine { Name = machineName ,Architecture = architecture };
				models.Config config = new models.Config {
					Name = configName ,
					Mono = String.Empty ,
					MonoOptions = new string[0] ,
					MonoEnvironmentVariables = new Dictionary<string ,string> () ,
					Count = ITERATIONS
				};
				runSet = AsyncContext.Run (() => models.RunSet.FromId (machine ,runSetId ,config ,mainCommit ,null ,null ,null /* TODO: logURL? */));
			}

			if (runSet == null && !cheat) {
				Logging.GetLogging ().Warn ("RunSetID " + runSetId + " not found");
				return;
			}
			new Task (() => {
				try {
					for (var i = 0; i < (ITERATIONS + DRY_RUNS); i++) {
						var run = Iteration (benchmarkName, i, i < DRY_RUNS);
						if (i >= DRY_RUNS && !cheat) {
							runSet.Runs.Add (run);
						}
					}
					if (!cheat) {
						var result = AsyncContext.Run (() => runSet.Upload ());
						RunOnUiThread (() => SetStartButtonText (result == null ? "failed" : "start"));
					} else {
						RunOnUiThread (() => SetStartButtonText ("start"));
					}
				} catch (Exception e) {
					RunOnUiThread (() => SetStartButtonText ("failed"));
					Logging.GetLogging ().Error (e);
				} finally {
					if (AndroidCPUManagment.IsRooted ()) {
						CpuManager.RestoreCPUStates ();
					}
				}
			}).Start ();
		}