Наследование: ApiObject
Пример #1
0
		public static async Task<RunSet> FromId (Machine local_machine, long local_runsetid, Config local_config, Commit local_mainCommit, List<Commit> local_secondaryCommits, string local_buildURL, string local_logURL)
		{
			using (var client = new HttpClient ()) {
				JObject db_result = await HttpApi.GetRunset (local_runsetid);
				if (db_result == null) {
					return null;
				}

				var runSet = new RunSet {
					Id = local_runsetid,
					StartDateTime = db_result ["StartedAt"].ToObject<DateTime> (),
					FinishDateTime = db_result ["FinishedAt"].ToObject<DateTime> (),
					BuildURL = db_result ["BuildURL"].ToObject<string> (),
					Machine = local_machine,
					LogURL = local_logURL,
					Config = local_config,
					Commit = local_mainCommit,
					TimedOutBenchmarks = db_result ["TimedOutBenchmarks"].ToObject<List<string>> (),
					CrashedBenchmarks = db_result ["CrashedBenchmarks"].ToObject<List<string>> ()
				};

				var db_mainProductCommit = db_result ["MainProduct"] ["Commit"].ToObject<string> ();
				if (local_mainCommit.Hash != db_mainProductCommit)
					throw new Exception (String.Format ("Commit ({0}) does not match the one in the database ({1}).", local_mainCommit.Hash, db_mainProductCommit));

				var db_secondaryCommits = new List<Commit> ();
				foreach (var sc in db_result ["SecondaryProducts"]) {
					db_secondaryCommits.Add (new Commit {
						Hash = sc ["Commit"].ToObject<string> (),
						Product = new Product { Name = sc ["Name"].ToObject<string> () }
					});
				}
				if (local_secondaryCommits != null) {
					if (local_secondaryCommits.Count != db_secondaryCommits.Count)
						throw new Exception ("Secondary commits don't match the database.");
					foreach (var sc in db_secondaryCommits) {
						if (!local_secondaryCommits.Any (c => c.Hash == sc.Hash && c.Product.Name == sc.Product.Name))
							throw new Exception ("Secondary commits don't match the database.");
					}
					// local commits have more information (e.g. datetime)
					runSet.SecondaryCommits = local_secondaryCommits;
				} else {
					runSet.SecondaryCommits = db_secondaryCommits;
				}


				if (local_buildURL != null && local_buildURL != runSet.BuildURL)
					throw new Exception ("Build URL does not match the one in the database.");
				
				var db_machineName = db_result ["Machine"] ["Name"].ToObject<string> ();
				var db_machineArchitecture = db_result ["Machine"] ["Architecture"].ToObject<string> ();
				if (local_machine.Name != db_machineName || local_machine.Architecture != db_machineArchitecture)
					throw new Exception ("Machine does not match the one in the database. \"" + db_machineName + "\" vs. \"" + local_machine.Name + "\"");

				if (!local_config.EqualsApiObject (db_result ["Config"]))
					throw new Exception ("Config does not match the one in the database.");

				return runSet;
			}
		}
Пример #2
0
        void RunBenchmark(long runSetId, string benchmarkName, string machineName, string architecture)
        {
            const int DRY_RUNS   = 3;
            const int ITERATIONS = 10;


            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        = "default", Mono = String.Empty,
                MonoOptions = new string[0],
                MonoEnvironmentVariables = new Dictionary <string, string> (),
                Count = ITERATIONS
            };
            models.RunSet runSet = AsyncContext.Run(() => models.RunSet.FromId(machine, runSetId, config, mainCommit, null, null, null /* TODO: logURL? */));

            if (runSet == null)
            {
                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)
                        {
                            runSet.Runs.Add(run);
                        }
                    }
                    var result = AsyncContext.Run(() => runSet.Upload());
                    if (result == null)
                    {
                        RunOnUiThread(() => SetStartButtonText("failed"));
                    }
                    else
                    {
                        RunOnUiThread(() => SetStartButtonText("start"));
                    }
                } catch (Exception e) {
                    RunOnUiThread(() => SetStartButtonText("failed"));
                    Logging.GetLogging().Error(e);
                } finally {
                    if (AndroidCPUManagment.IsRooted())
                    {
                        CpuManager.RestoreCPUStates();
                    }
                }
            }).Start();
        }
Пример #3
0
		public UnixRunner (string testsDirectory, Config _config, Benchmark _benchmark, Machine _machine, int _timeoutSeconds, string _runTool, string _runToolArguments)
		{
			config = _config;
			benchmark = _benchmark;
			machine = _machine;
			defaultTimeoutSeconds = _timeoutSeconds;
			runTool = _runTool;
			runToolArguments = _runToolArguments;

			var binaryProtocolFile = _config.ProducesBinaryProtocol ? "binprot.dummy" : null;
			Info = compare.Utils.NewProcessStartInfo (_config, binaryProtocolFile);

			Info.WorkingDirectory = Path.Combine (testsDirectory, benchmark.TestDirectory);

			if (config.AOTOptions != null) {
				if (benchmark.AOTAssemblies == null) {
					Console.Error.WriteLine("Error: benchmark {0} not configured to be executed in AOT mode.", benchmark.Name);
					Environment.Exit(1);
				}
				InfoAot = compare.Utils.NewProcessStartInfo (_config, binaryProtocolFile);
				InfoAot.WorkingDirectory = Path.Combine (testsDirectory, benchmark.TestDirectory);
				InfoAot.Arguments = String.Join (" ", config.AOTOptions.Concat (benchmark.AOTAssemblies));
			}

			var commandLine = benchmark.CommandLine;

			if (benchmark.ClientCommandLine != null) {
				clientServer = true;
				ClientInfo = compare.Utils.NewProcessStartInfo (_config, binaryProtocolFile);
				ClientInfo.WorkingDirectory = Info.WorkingDirectory;
				ClientInfo.Arguments = String.Join (" ", config.MonoOptions.Concat (benchmark.ClientCommandLine));
			} else {
				clientServer = false;
			}

			if (config.NoMono) {
				Info.FileName = Path.Combine (Info.WorkingDirectory, commandLine [0]);
				commandLine = commandLine.Skip (1).ToArray ();
			}

			fileName = Info.FileName;

			arguments = String.Join (" ", config.MonoOptions.Concat (commandLine));
			/* Run with timing */
			if (!config.NoMono)
				arguments = "--stats " + arguments;
		}
Пример #4
0
		public UnixRunner (string testsDirectory, Config _config, Benchmark _benchmark, Machine _machine, int _timeoutSeconds, string _runTool, string _runToolArguments)
		{
			config = _config;
			benchmark = _benchmark;
			machine = _machine;
			defaultTimeoutSeconds = _timeoutSeconds;
			runTool = _runTool;
			runToolArguments = _runToolArguments;

			var binaryProtocolFile = _config.ProducesBinaryProtocol ? "binprot.dummy" : null;
			info = compare.Utils.NewProcessStartInfo (_config, binaryProtocolFile);

			info.WorkingDirectory = Path.Combine (testsDirectory, benchmark.TestDirectory);

			var commandLine = benchmark.CommandLine;

			if (benchmark.ClientCommandLine != null) {
				clientServer = true;
				clientInfo = compare.Utils.NewProcessStartInfo (_config, binaryProtocolFile);
				clientInfo.WorkingDirectory = info.WorkingDirectory;
				clientInfo.Arguments = String.Join (" ", config.MonoOptions.Concat (benchmark.ClientCommandLine));
			} else {
				clientServer = false;
			}

			if (config.NoMono) {
				info.FileName = Path.Combine (info.WorkingDirectory, commandLine [0]);
				commandLine = commandLine.Skip (1).ToArray ();
			}

			fileName = info.FileName;

			arguments = String.Join (" ", config.MonoOptions.Concat (commandLine));
			/* Run with timing */
			if (!config.NoMono)
				arguments = "--stats " + arguments;
		}
Пример #5
0
		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 ();
		}