public CallResult GetTestStringFromDatabase() //Backend, but... :) { StopWatchTimer timer = new StopWatchTimer(); timer.Start("Test database"); ///Create test values in database timer.StartNewLap("Save to database"); ///This is backend //TODO: move this to backend? TestData testDataValue = TestData.New(); const string TextToTestDatabaseIoWith = "Hello from database!;)"; testDataValue.TestText = TextToTestDatabaseIoWith; testDataValue.Save(); timer.StartNewLap("Read data from database"); var entryRead = TestData.ReadFirst("ID = @ID", "@ID", testDataValue.ID); ///end of Backend code ??? timer.Stop(); var response = string.Format("</br>Text from database: \"{0}\", </br> timer log: </br> {1}", entryRead.TestText, timer.ToString().Replace("\n", "</br>")); testDataValue.Delete(); return(new CallResult(response)); }
protected async Task Processing() { StopWatchTimer.Start(); TimeSpan?next = null; TimeSpan now; do { await BenchmarkingTarget(); Iterations++; now = StopWatchTimer.Elapsed; next = now > next ? now + PerfCollector.TryRead(): next ?? (now + PerfCollector.TryRead()); } while (now < TimeSpan); StopWatchTimer.Stop(); ElapsedMilliseconds = StopWatchTimer.ElapsedMilliseconds; StopWatchTimer = null; }
public void TestStopWatch() { Console.WriteLine(StopWatchTimer.Start()); Thread.Sleep(7000); Console.WriteLine(StopWatchTimer.Stop()); }
//Start Button & Clock In Start private void btnStart_Click(object sender, EventArgs e) { StopWatchTimer.Start(); ClockIn.Text = DateTime.Now.ToString(); }