public void DoubleStartTest() { var profiler = new Profiler(); profiler.Start(); profiler.Start(); }
static void FindStringsWithSuffix_UsingSubString(IEnumerable <string> strings, string suffix) { output.Clear(); profiler.Start(); foreach (var s in strings) { if (s.Substring(s.Length - 4) == suffix) { output.Add(s); } } profiler.Stop(); }
public void DoubleStartAndStopTest() { var actualSeconds = 2; var profiler = new Profiler(); profiler.Start(); Thread.Sleep(actualSeconds * 1000); profiler.Start(); var actual1 = profiler.Stop(); var actual2 = profiler.Stop(); Assert.AreNotSame(actual1.Seconds, actual2.Seconds); }
public override void OnCreate() { base.OnCreate(); Profiler.Start("OnResume"); CrossCurrentActivity.Current.Init(this); //Set the default notification channel for your app when running Android Oreo if (Build.VERSION.SdkInt >= BuildVersionCodes.O) { //Change for your default notification channel id here FirebasePushNotificationManager.DefaultNotificationChannelId = "FirebasePushNotificationChannel"; //Change for your default notification channel name here FirebasePushNotificationManager.DefaultNotificationChannelName = "General"; } FirebasePushNotificationManager.Initialize(this, false); //Handle notification when app is closed here CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) => { if (Xamarin.Forms.Application.Current == null || !IsInForeground()) { bool isAlarmActive = Preferences.Get(Constants.PreferenceAlarmActivate, Constants.PreferenceAlarmActivateDefault); var operation = OperationHelper.MapFirebaseToOperation(p.Data); if (isAlarmActive && p.Data != null) { Intent intent = new Intent(this, typeof(MainActivity)); intent.PutExtra(INTENT_EXTRA_OPERATION, JsonConvert.SerializeObject(operation)); StartActivity(intent); } } }; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, Profiler profiler) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); // Manually call .Start() which will patch the methods and start profiling profiler.Start(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseStaticFiles(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); }
protected void Application_BeginRequest(object src, EventArgs e) { if (Request.IsLocal) { Profiler.Start(); } }
static void ReduceVectors(CudaDataSet <int> teaching, CudaDataSet <int> test) { using (CudaContext context = new CudaContext()) { int popSize = 100; DeviceDataSet <int> deviceTeaching = new DeviceDataSet <int>(teaching); DeviceDataSet <int> deviceTest = new DeviceDataSet <int>(test); FlattArray <byte> initialPopulation; VectorReductionAccuracy acc = new VectorReductionAccuracy(context, deviceTeaching, deviceTest, popSize) { K = 5, CountToPass = 3 }; VectorReductionFitness fitnessFunc = new VectorReductionFitness(context, acc, popSize, deviceTeaching.length) { Alpha = 0.7f }; //Drop3 drop = new Drop3(); //drop.CasheSize = 5; //drop.K = 3; //Profiler.Start("Drop3"); //var indexesToStay = drop.Apply(teaching, context); //Profiler.Stop("Drop3"); //byte[] parrent = new byte[teaching.Vectors.GetLength(0)]; //foreach (var item in indexesToStay) //{ // parrent[item] = 1; //} initialPopulation = CreateRandomPopulation(popSize, deviceTeaching.length); //CreatePopulationBasedOnParent(parrent, popSize, 0.2f, 0.05f); var d = new Evolutionary2(context, fitnessFunc, initialPopulation) { Elitism = 0.001f, MutationRate = 0.001f }; for (int i = 0; i < 30; i++) { Profiler.Start("iteration"); d.CreateNewPopulation(); Profiler.Stop("iteration"); } var best = d.FindFitest(); Console.WriteLine(acc.GenAccuracy(best.index) / (float)deviceTest.length); Console.WriteLine(fitnessFunc.GenLength(best.index)); Profiler.Print(); } }
private void DoCommit(VersionNode version) { Profiler.Start($"Adding commit for {version.Version}"); // extract string workspace = Path.Combine(Path.GetTempPath(), "mc_version_history_workspace"); if (Directory.Exists(workspace)) { Directory.Delete(workspace, true); } Directory.CreateDirectory(workspace); Profiler.Run("Extracting", () => { version.Version.ExtractData(workspace, Config); }); Profiler.Run("Translating NBT Files", () => { TranslateNbtFiles(workspace); }); Profiler.Run($"Merging", () => { MergeWithWorkspace(VersionConfig.GitRepo.Folder, workspace); Directory.Delete(workspace, true); Util.RemoveEmptyFolders(VersionConfig.GitRepo.Folder); File.WriteAllText(Path.Combine(VersionConfig.GitRepo.Folder, "version.txt"), version.Version.Name); }); // commit Profiler.Start($"Running git commit"); VersionConfig.GitRepo.Commit(version.Version.Name, version.Version.ReleaseTime); string hash = VersionConfig.GitRepo.BranchHash("HEAD"); CommitToVersion.Add(hash, version); VersionToCommit.Add(version, hash); Profiler.Stop(); // git commit Profiler.Stop(); // top commit }
protected void Application_BeginRequest(object sender, EventArgs e) { if (Properties.Settings.Default.UseProfiler) { Profiler.Start(); } }
private void DoEnvironment(object discarded) { if (ShuttingDown) { return; } long start = Time.ElapsedMilliseconds; long limit = Time.ElapsedMilliseconds + MillisecondsPerTick; Profiler.Start("environment"); Scheduler.Update(); Profiler.Start("environment.entities"); foreach (var manager in EntityManagers) { manager.Update(); } Profiler.Done(); if (Program.ServerConfiguration.EnableLighting) { Profiler.Start("environment.lighting"); foreach (var lighter in WorldLighters) { while (Time.ElapsedMilliseconds < limit && lighter.TryLightNext()) { // This space intentionally left blank } if (Time.ElapsedMilliseconds >= limit) { Log(LogCategory.Warning, "Lighting queue is backed up"); } } Profiler.Done(); } if (Program.ServerConfiguration.EnableEventLoading) { Profiler.Start("environment.chunks"); Tuple <IWorld, IChunk> t; if (ChunksToSchedule.TryTake(out t)) { ScheduleUpdatesForChunk(t.Item1, t.Item2); } Profiler.Done(); } Profiler.Done(MillisecondsPerTick); long end = Time.ElapsedMilliseconds; long next = MillisecondsPerTick - (end - start); if (next < 0) { next = 0; } EnvironmentWorker.Change(next, Timeout.Infinite); }
public VectorReductionAccuracy(CudaContext context, DeviceDataSet <int> teaching, DeviceDataSet <int> test, int popSize) { this.teaching = teaching; this.test = test; this.popSize = popSize; this.context = context; calculatedNeabours = new CudaDeviceVariable <int>(teaching.length * test.length); deviceAccuracy = new CudaDeviceVariable <float>(popSize); Profiler.Start("calculate neabours"); Neabours.CalculateNeabours(context, teaching, test, calculatedNeabours, ThreadsPerBlock); Profiler.Stop("calculate neabours"); accuracyKernel = context.LoadKernel("kernels/VectorReduction.ptx", "calculateAccuracy"); dim3 gridDimension = new dim3() { x = (uint)(test.length / ThreadsPerBlock + 1), y = (uint)popSize, z = 1 }; accuracyKernel.GridDimensions = gridDimension; accuracyKernel.BlockDimensions = ThreadsPerBlock; accuracyKernel.SetConstantVariable("testVectorsCount", test.length); accuracyKernel.SetConstantVariable("teachingVectorsCount", teaching.length); accuracyKernel.SetConstantVariable("attributeCount", teaching.attributeCount); accuracyKernel.SetConstantVariable("genLength", teaching.length); K = 3; CountToPass = 2; }
/// <summary> /// Sends server control content to a provided <see cref="T:System.Web.UI.HtmlTextWriter"></see> object, which writes the content to be rendered on the client. /// </summary> /// <param name="output">The <see cref="T:System.Web.UI.HtmlTextWriter"></see> object that receives the server control content.</param> /// <exception cref="Glass.Mapper.Sc.Razor.RazorException"></exception> /// <remarks>When developing custom server controls, you can override this method to generate content for an ASP.NET page.</remarks> protected override void DoRender(HtmlTextWriter output) { Model = GetModel(); var viewContents = GetRazorView(View); try { Profiler.Start("Razor engine {0}".Formatted(this.View)); var template = RazorEngine.Razor.CreateTemplate(viewContents, Model) as TemplateBase <T>; template.Configure(SitecoreService, ViewData, this); output.Write(template.CastTo <ITemplate <T> >().Run(new ExecuteContext())); Profiler.Start("Razor engine {0}".Formatted(this.View)); } catch (RazorEngine.Templating.TemplateCompilationException ex) { StringBuilder errors = new StringBuilder(); ex.Errors.ForEach(x => { errors.AppendLine("File: {0}".Formatted(View)); errors.AppendLine(x.ErrorText); }); throw new RazorException(errors.ToString()); } }
protected void Application_BeginRequest(object sender, EventArgs e) { if (Profile) { Profiler.Start(); } }
protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); CheckPlayService(); Forms.SetFlags("FastRenderers_Experimental"); Profiler.Start("Forms.Init"); Forms.Init(this, bundle); Xamarin.FormsMaps.Init(this, bundle); Xamarin.Essentials.Platform.Init(this, bundle); Profiler.Stop("Forms.Init"); Profiler.Start("LoadApplication"); LoadApplication(_app.Value); Profiler.Stop("LoadApplication"); if (!CheckOperationJson(Intent)) { FirebasePushNotificationManager.ProcessIntent(this, Intent); } }
private void Callback_PreviewUpdated(object sender, PreviewUpdatedEventArgs e) { Profiler.End("Captured"); Profiler.Start("Captured"); if (FrameReady == null) { return; } frameCount++; if (MultiThread) { if (e.Buffer != null && LimitedTaskScheduler.QueuedTaskCount < LimitedTaskScheduler.MaxTaskCount) { LimitedTaskScheduler.Factory.StartNew(() => CaptureCvtProc(e.Buffer, frameCount, LimitedTaskScheduler.QueuedTaskCount)); } } else { CaptureCvtProc(e.Buffer, 0, 0); } Profiler.Capture("TaskCount", LimitedTaskScheduler.QueuedTaskCount); }
private void RunDataGenerators(JavaConfig config, string folder) { string reports_path = Path.Combine(config.ServerJarFolder, "generated"); if (Directory.Exists(reports_path)) { Directory.Delete(reports_path, true); } DownloadServerJar(config); if (Server.JarPath is not null) { Profiler.Start("Fetching data reports"); string args1 = $"-cp \"{Server.JarPath}\" net.minecraft.data.Main --reports"; string args2 = $"-DbundlerMainClass=net.minecraft.data.Main -jar \"{Server.JarPath}\" --reports"; var result = CommandRunner.RunJavaCombos( config.ServerJarFolder, config.JavaInstallationPaths, new[] { args1, args2 } ); if (result.ExitCode != 0) { throw new ApplicationException("Failed to get data reports"); } Directory.CreateDirectory(folder); FileSystem.CopyDirectory(Path.Combine(reports_path, "reports"), folder); if (Directory.Exists(reports_path)) { Directory.Delete(reports_path, true); } Profiler.Stop(); } }
public async Task Test_04_Exceptions() { Profiler Profiler = new Profiler(); Profiler.Start(); Task T1 = Task.Run(async() => { await Task.Delay(rnd.Next(10, 1000)); Profiler.NewState("A"); await Task.Delay(rnd.Next(10, 1000)); Profiler.NewState("B"); await Task.Delay(rnd.Next(10, 1000)); Profiler.NewState("C"); await Task.Delay(rnd.Next(10, 1000)); Profiler.NewState("D"); await Task.Delay(rnd.Next(10, 1000)); }); Task T2 = Task.Run(async() => { int i; for (i = 0; i < 100; i++) { Profiler.Exception(new InvalidOperationException("Invalid operation.")); await Task.Delay(rnd.Next(1, 100)); } }); await Task.WhenAll(T1, T2); Profiler.Stop(); this.ExportResults(Profiler, "Test_04_Exceptions"); }
//[CallOnThread("Updater")] public void Update() { Profiler.Start(); try { watchdogToken.Ping(); CurrentFrame.Clear(); foreach (GameComponent component in GameComponents) { if (component.Enabled) { component.Update(gameTime); } } if (game.State != null) { game.State.Update(CurrentFrame, gameTime.TotalGameTime.TotalSeconds, gameTime); CurrentFrame.Sort(); } } finally { Profiler.Stop(); } }
public async Task Test_03_Events() { Profiler Profiler = new Profiler(); Profiler.Start(); Task T1 = Task.Run(async() => { await Task.Delay(rnd.Next(10, 1000)); Profiler.NewState("A"); await Task.Delay(rnd.Next(10, 1000)); Profiler.NewState("B"); await Task.Delay(rnd.Next(10, 1000)); Profiler.NewState("C"); await Task.Delay(rnd.Next(10, 1000)); Profiler.NewState("D"); await Task.Delay(rnd.Next(10, 1000)); }); Task T2 = Task.Run(async() => { int i; for (i = 0; i < 100; i++) { Profiler.Event(new string((char)(rnd.Next(0, 10) + 'A'), 1)); await Task.Delay(rnd.Next(1, 100)); } }); await Task.WhenAll(T1, T2); Profiler.Stop(); this.ExportResults(Profiler, "Test_03_Events"); }
public Updater(AppConfig config) { Config = config; Profiler.Start("Building version graph"); Graph = CreateGraph(); Profiler.Stop(); }
private void InsertCommit(VersionNode version) { // find commit hash for existing version string hash = VersionToCommit[version.Parent]; // create branch var branchname = GetBranchName(version); VersionConfig.GitRepo.MakeBranch(branchname, hash); // if this commit is the most recent for this branch, we can just commit right on top without insertion logic string tophash = VersionConfig.GitRepo.BranchHash(branchname); if (hash == tophash) { VersionConfig.GitRepo.Checkout(branchname); DoCommit(version); } else { Console.WriteLine($"Needs to insert into history for this one"); // make a branch that starts there and prepare to commit to it VersionConfig.GitRepo.CheckoutBranch("temp", hash); VersionConfig.GitRepo.MakeBranch(branchname); DoCommit(version); // insert Profiler.Start($"Rebasing"); VersionConfig.GitRepo.Rebase("temp", branchname); VersionConfig.GitRepo.Checkout(branchname); VersionConfig.GitRepo.DeleteBranch("temp"); Profiler.Stop(); // need to rescan since commit hashes change after a rebase LoadCommits(); } }
private void CheckAndDamagePlayer() { var character = MyAPIGateway.Session.Player?.Controller?.ControlledEntity?.Entity as IMyCharacter; if (character == null) { return; } var damageBlock = Profiler.Start("0.ShipyardMod.ShipyardCore", nameof(CheckAndDamagePlayer)); BoundingBoxD charbox = character.WorldAABB; MyAPIGateway.Parallel.ForEach(Communication.LineDict.Values.ToArray(), lineList => { foreach (LineItem line in lineList) { var ray = new Ray(line.Start, line.End - line.Start); double?intersection = charbox.Intersects(ray); if (intersection.HasValue) { if (Vector3D.DistanceSquared(charbox.Center, line.Start) < Vector3D.DistanceSquared(line.Start, line.End)) { Utilities.Invoke(() => character.DoDamage(5, MyStringHash.GetOrCompute("ShipyardLaser"), true)); } } } }); damageBlock.End(); }
private void MergeWithWorkspace(string base_folder, string workspace) { // delete files that are not present in workspace Profiler.Start("Deleting"); foreach (var item in Directory.GetFiles(base_folder, "*", SearchOption.AllDirectories)) { string relative = Path.GetRelativePath(base_folder, item); if (relative.StartsWith(".git")) { continue; } string workspace_version = Path.Combine(workspace, relative); if (!File.Exists(workspace_version)) { File.Delete(item); } } Profiler.Stop(); // copy new/changed files from workspace Profiler.Start("Copying"); foreach (var item in Directory.GetFiles(workspace, "*", SearchOption.AllDirectories)) { string relative = Path.GetRelativePath(workspace, item); string base_version = Path.Combine(base_folder, relative); if (!File.Exists(base_version) || !Util.FilesAreEqual(new FileInfo(item), new FileInfo(base_version))) { Util.Copy(item, base_version); } File.Delete(item); } Profiler.Stop(); }
public void Start_Test() { Profiler target = new Profiler(); target.Start(); Assert.IsTrue(target.Enabled); }
private void CreateLightMap() { Profiler.Start("Draw Lighting"); int j = 0, k = 0; Globe.GraphicsDevice.SetRenderTarget(_lightMap); Globe.GraphicsDevice.Clear(Color.White); Screen.Setup(); for (var x = _tilesMinX; x <= _tilesMaxX; x++) { for (var y = _tilesMinY; y <= _tilesMaxY; y++) { var t = Tiles[x, y]; if (t.Light < byte.MaxValue) { Screen.Draw(_blackPixel, new Rectangle(j, k, 1, 1), new Color(255, 255, 255, 255 - Math.Min((ushort)255, t.Light))); } k++; } j++; k = 0; } Screen.Cease(); Globe.GraphicsDevice.SetRenderTarget(null); Profiler.Stop("Draw Lighting"); }
protected void BeforeEachTest() { this.cts = new CancellationTokenSource(Context.Current.TestTimeout); this.testStartTime = DateTime.Now; this.profiler = Profiler.Start(); Log.Information("Running test '{Name}'", TestContext.CurrentContext.Test.Name); }
public void Update() { Profiler.Start("scheduler"); lock (EventLock) { var start = Stopwatch.ElapsedTicks; for (int i = 0; i < Events.Count; i++) { var e = Events[i]; if (e.When <= start) { Profiler.Start("scheduler." + e.Name); e.Action(Server); Events.RemoveAt(i); i--; Profiler.Done(); } if (e.When > start) { break; // List is sorted, we can exit early } } } Profiler.Done(20); }
protected void Application_BeginRequest(object sender, EventArgs e) { if (Request.IsLocal) { Profiler.Start(ProfileLevel.Verbose); } }
public void CalculateFitness(CudaDeviceVariable <byte> population, CudaDeviceVariable <float> fitness) { Profiler.Start("Calculate accuracy"); var deviceAccuracy = accuracyCalc.CalculateAccuracy(population); Profiler.Stop("Calculate accuracy"); float[] asdf = deviceAccuracy; Profiler.Start("Calculate vectorSizes"); countVectorsKernel.Calculate(population, vectorSizes); Profiler.Stop("Calculate vectorSizes"); int[] v = vectorSizes; Profiler.Start("Avrage VectorSizes"); float avrageVectorSize = Thrust.Avrage(vectorSizes); Profiler.Stop("Avrage VectorSizes"); Profiler.Start("Avrage accuracy"); float avrageAccuracy = Thrust.Avrage(deviceAccuracy); Profiler.Stop("Avrage accuracy"); Profiler.Start("fittness kernel"); fitnessKernel.Run( deviceAccuracy.DevicePointer, avrageAccuracy, vectorSizes.DevicePointer, avrageVectorSize, fitness.DevicePointer ); Profiler.Stop("fittness kernel"); }
public void Merge(string layer_folder, string output_folder) { Profiler.Start("Merging vanilla packs"); foreach (var layer in Layers) { var pack = Path.Combine(layer_folder, layer); if (!Directory.Exists(pack)) { Console.WriteLine($"Skipping {layer} (doesn't exist)"); continue; } Console.WriteLine($"Applying {layer}"); foreach (var file in Directory.GetFiles(pack, "*", SearchOption.AllDirectories)) { var relative = Path.GetRelativePath(pack, file); var dest = Path.Combine(output_folder, relative); var specs = MergingSpecs.Where(x => x.Matches(relative)); Directory.CreateDirectory(Path.GetDirectoryName(dest)); if (specs.Any()) { foreach (var spec in specs) { spec.MergeFiles(dest, file); } } else { Util.Copy(file, dest); } } } Profiler.Stop(); }