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(); }
protected override void OnCreate(Bundle savedInstanceState) { string architecture = Android.OS.Build.CpuAbi; base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); FindViewById <Button> (Resource.Id.myButton).Click += delegate { string benchmarkName = FindViewById <TextView> (Resource.Id.benchmark).Text; string githubAPIKey = FindViewById <TextView> (Resource.Id.githubAPIKey).Text; string httpAPITokens = FindViewById <TextView> (Resource.Id.httpAPITokens).Text; string machineName = FindViewById <TextView> (Resource.Id.machineName).Text; long runSetId = Int64.Parse(FindViewById <TextView> (Resource.Id.runSetId).Text); string configName = FindViewById <TextView> (Resource.Id.configName).Text; InitCommons(githubAPIKey, httpAPITokens); SetStartButtonText("running"); RunBenchmark(runSetId, benchmarkName, machineName, architecture, configName); }; string v = ".NET version:\n" + System.Environment.Version.ToString(); v += "\n\nMonoVersion:\n" + GetMonoVersion(); v += "\nArchitecture: " + architecture; FindViewById <TextView> (Resource.Id.versionText).Text = v; Logging.GetLogging().Info(v); #if false if (AndroidCPUManagment.IsRooted()) { Logging.GetLogging().Info("Ohai: On a rooted device!"); CpuManager = new AndroidCPUManagment(); CpuManager.ConfigurePerformanceMode(); } else { Logging.GetLogging().Warn("device not rooted, thus can't set CPU frequency: expect flaky results"); } #endif Logging.GetLogging().Info("OnCreate finished"); }
protected override void OnCreate (Bundle savedInstanceState) { string architecture = Android.OS.Build.CpuAbi; base.OnCreate (savedInstanceState); // Set our view from the "main" layout resource SetContentView (Resource.Layout.Main); FindViewById<Button> (Resource.Id.myButton).Click += delegate { string benchmarkName = FindViewById<TextView> (Resource.Id.benchmark).Text; string githubAPIKey = FindViewById<TextView> (Resource.Id.githubAPIKey).Text; string httpAPITokens = FindViewById<TextView> (Resource.Id.httpAPITokens).Text; string machineName = FindViewById<TextView> (Resource.Id.machineName).Text; long runSetId = Int64.Parse (FindViewById<TextView> (Resource.Id.runSetId).Text); string configName = FindViewById<TextView> (Resource.Id.configName).Text; InitCommons (githubAPIKey, httpAPITokens); SetStartButtonText ("running"); RunBenchmark (runSetId, benchmarkName, machineName, architecture, configName); }; string v = ".NET version:\n" + System.Environment.Version.ToString (); v += "\n\nMonoVersion:\n" + GetMonoVersion (); v += "\nArchitecture: " + architecture; FindViewById<TextView> (Resource.Id.versionText).Text = v; Logging.GetLogging ().Info (v); #if false if (AndroidCPUManagment.IsRooted ()) { Logging.GetLogging ().Info ("Ohai: On a rooted device!"); CpuManager = new AndroidCPUManagment (); CpuManager.ConfigurePerformanceMode (); } else { Logging.GetLogging ().Warn ("device not rooted, thus can't set CPU frequency: expect flaky results"); } #endif Logging.GetLogging ().Info ("OnCreate finished"); }