internal GetStreamCountCollector(SessionCounters sessionCounters) { m_sessionCounters = sessionCounters; m_elapsed = ElapsedTimer.StartNew(); m_copyStats = new CasCopyStats(); m_finalCounter = null; }
internal GetStreamCountCollector(SessionCounters sessionCounters) { m_sessionCounters = sessionCounters; m_elapsed = ElapsedTimer.StartNew(); m_state = State.Hit; m_size = 0; }
internal IncorporateRecordsCountCollector(SessionCounters sessionCounters) { Contract.Requires(sessionCounters != null); m_sessionCounters = sessionCounters; m_elapsed = ElapsedTimer.StartNew(); }
internal ValidateContentCountCollector(SessionCounters sessionCounters) { m_sessionCounters = sessionCounters; m_elapsed = ElapsedTimer.StartNew(); m_state = ValidateContentStatus.NotSupported; m_size = 0; }
public void Add(double localCount, double remoteCount, long sentinelCount, ElapsedTimer time) { m_count.Add(); m_local.Add(localCount); m_remote.Add(remoteCount); m_sentinel.Add(sentinelCount); m_time.Add(time.TotalMilliseconds); }
internal EnumerateStrongFingerprintsCountCollector(SessionCounters sessionCounters) { Contract.Requires(sessionCounters != null); m_sessionCounters = sessionCounters; m_elapsed = ElapsedTimer.StartNew(); m_count = 0; }
internal GetCacheEntryCountCollector(SessionCounters sessionCounters) { Contract.Requires(sessionCounters != null); m_sessionCounters = sessionCounters; m_elapsed = ElapsedTimer.StartNew(); m_hit = false; }
internal PinToCasCountCollector(SessionCounters sessionCounters) { Contract.Requires(sessionCounters != null); m_sessionCounters = sessionCounters; m_elapsed = ElapsedTimer.StartNew(); m_theCounter = m_sessionCounters.m_pinToCas_Hit; }
internal CloseCountCollector(SessionCounters sessionCounters) { Contract.Requires(sessionCounters != null); m_sessionCounters = sessionCounters; m_elapsed = ElapsedTimer.StartNew(); m_count = 0; }
internal ProduceFileCountCollector(SessionCounters sessionCounters) { Contract.Requires(sessionCounters != null); m_sessionCounters = sessionCounters; m_elapsed = ElapsedTimer.StartNew(); m_finalCounter = null; m_copyStats = new CasCopyStats(); }
internal ProduceFileCountCollector(SessionCounters sessionCounters) { Contract.Requires(sessionCounters != null); m_sessionCounters = sessionCounters; m_elapsed = ElapsedTimer.StartNew(); m_state = State.Hit; m_size = 0; }
public void ElapsedTimer_Running() { var timer = new ElapsedTimer(true); Thread.Sleep(1000); Assert.IsTrue(Compare(1000, timer.ElapsedTime)); Thread.Sleep(1000); Assert.IsTrue(Compare(2000, timer.ElapsedTime)); }
internal AddOrGetCountCollector(SessionCounters sessionCounters) { Contract.Requires(sessionCounters != null); m_sessionCounters = sessionCounters; m_elapsed = ElapsedTimer.StartNew(); m_theCounter = m_sessionCounters.m_addOrGet_New; m_entriesCount = 0; }
internal AddToCasCountCollector(SessionCounters sessionCounters) { Contract.Requires(sessionCounters != null); m_sessionCounters = sessionCounters; m_elapsed = ElapsedTimer.StartNew(); m_writeThrough = false; m_copyStats = new CasCopyStats(); }
internal AddOrGetCountCollector(SessionCounters sessionCounters) { Contract.Requires(sessionCounters != null); m_sessionCounters = sessionCounters; m_elapsed = ElapsedTimer.StartNew(); m_uploadDisregarded = false; m_finalCounter = null; m_copyStats = new CasCopyStats(); }
internal AddToCasCountCollector(SessionCounters sessionCounters, bool file) { Contract.Requires(sessionCounters != null); m_sessionCounters = sessionCounters; m_elapsed = ElapsedTimer.StartNew(); m_file = file; m_size = 0; m_theCounter = m_file ? m_sessionCounters.m_addToCas_File_New : m_sessionCounters.m_addToCas_Stream_New; }
private void BtnInstall_OnClick(object sender, RoutedEventArgs e) { if (_installList.Count == 0) { MessageBox.Show(Localization.GetString("Global", 50), Localization.GetString("Global", 51)); return; } lblStatus.Text = Localization.GetString("Global", 48); pbProgress.Value = 0; pbProgress.Maximum = _installList.Count; lblProgress.Content = "0%"; dgUpdates.Disable(); rbnMain.IsEnabled = false; _tim = new ElapsedTimer(ref txtTime); _tim.Start(); var amountInstalled = 0; Task.Factory.StartNew(delegate { foreach (var currentFile in _installList) { currentFile.Status = currentFile.Install(); amountInstalled++; pbProgress.Dispatcher.BeginInvoke(new Action(() => { pbProgress.Value++; var progress = (pbProgress.Value / pbProgress.Maximum) * 100; lblStatus.Text = amountInstalled + " / " + _installList.Count + " " + Localization.GetString("Global", 62); lblProgress.Content = Math.Round(progress, 1) + "%"; dgUpdates.Items.Refresh(); })); } }).ContinueWith(continuation => { _tim.Stop(); lblStatus.Dispatcher.BeginInvoke(new Action(() => { lblStatus.Text = _installList.Count(c => c.Status == Status.Success) + " " + Localization.GetString("FrmLMM", 8); dgUpdates.Enable(); rbnMain.IsEnabled = true; })); }); }
public void ElapsedTimer_Reset() { ElapsedTimer timer; timer = new ElapsedTimer(true); Thread.Sleep(1000); timer.Stop(); Assert.IsTrue(Compare(1000, timer.ElapsedTime)); timer.Reset(); Assert.AreEqual(TimeSpan.Zero, timer.ElapsedTime); }
public void ElapsedTimer_Using() { ElapsedTimer timer; timer = new ElapsedTimer(true); using (timer) { Thread.Sleep(1000); } Thread.Sleep(1000); Assert.IsTrue(Compare(1000, timer.ElapsedTime)); }
public void SetElapsedTimerGUIToLoseSettings(float x, float y, float z) { GameObject go = GameObject.Find("ElapsedTimer"); _elapsedTimer = (ElapsedTimer) go.GetComponent(typeof(ElapsedTimer)); // Set location of gui text _elapsedTimer.transform.position = new Vector3(x, y, z); // Apply other properties _elapsedTimer.FreezeTimeUpdating(); _elapsedTimer.SetFontSize(30); _elapsedTimer.SetFontStyleToBold(); _elapsedTimer.AlignToCenter(); _elapsedTimer.SetTextColor(Color.magenta); _elapsedTimer.SetText("Total Time:\n" + _elapsedTimer.GetCurrentText()); }
public void ElapsedTimer_MultiRun() { ElapsedTimer timer; timer = new ElapsedTimer(true); Thread.Sleep(1000); timer.Stop(); Thread.Sleep(1000); timer.Start(); Thread.Sleep(1000); timer.Stop(); Assert.IsTrue(Compare(2000, timer.ElapsedTime)); }
private async void addUpdate(IEnumerable <string> files) { dgUpdates.Disable(); pbProgress.Value = 0; lblProgress.Content = "0%"; var source = files.ToArray(); pbProgress.Maximum = source.Count(); _tim = new ElapsedTimer(ref txtTime); _tim.Start(); await Task.Factory.StartNew(delegate { Parallel.ForEach(source, new ParallelOptions { MaxDegreeOfParallelism = Options.MaxThreads }, currentFile => { _Update newUpdate = null; if (currentFile.EndsWithIgnoreCase(".cab")) { newUpdate = new CabUpdate(currentFile); } else if (currentFile.EndsWithIgnoreCase(".msu")) { newUpdate = new MsuUpdate(currentFile); } pbProgress.Increment(lblProgress); if (newUpdate == null) { return; } _updates.Add(newUpdate); }); }); _tim.Stop(); dgUpdates.ItemsSource = _updates; dgUpdates.Update(); }
public void ElapsedTimer_Basic() { ElapsedTimer timer; // Timer not started #1 timer = new ElapsedTimer(); Thread.Sleep(200); Assert.AreEqual(TimeSpan.Zero, timer.ElapsedTime); Thread.Sleep(1000); timer.Stop(); Assert.AreEqual(TimeSpan.Zero, timer.ElapsedTime); // Timer not started #2 timer = new ElapsedTimer(false); Thread.Sleep(200); Assert.AreEqual(TimeSpan.Zero, timer.ElapsedTime); Thread.Sleep(1000); timer.Stop(); Assert.AreEqual(TimeSpan.Zero, timer.ElapsedTime); // Timer started manually timer = new ElapsedTimer(false); Thread.Sleep(200); Assert.AreEqual(TimeSpan.Zero, timer.ElapsedTime); timer.Start(); Thread.Sleep(1000); timer.Stop(); Assert.IsTrue(Compare(1000, timer.ElapsedTime)); // Timer started automatically timer = new ElapsedTimer(true); Assert.AreEqual(TimeSpan.Zero, timer.ElapsedTime); timer.Start(); Thread.Sleep(1000); timer.Stop(); Assert.IsTrue(Compare(1000, timer.ElapsedTime)); }
//public static void main(String[] args) { void test() { // not sure but it doesnt look like "list" is actually used //LinkedList<TreeNode> list = new LinkedList<TreeNode>(); //List<TreeNode> list = new LinkedList<TreeNode>(); //list.add(null); //System.out.println("list: " + list); //TreeNode tn = new TreeNode(); //list.AddLast (tn); // try this ElapsedTimer t = new ElapsedTimer(); //int n = 1000; for (int i = 0; i < simulationCount; i++) { tn.selectAction(); } Debug.Log("MCTS elapsed: " + t.toString()); //System.out.println(t); //TreeView tv = new TreeView(tn); //tv.showTree("After " + n + " play outs"); //Debug.Log("Done."); }
public void IPToGeocode_Query_AsyncBlast() { // Blast 100,000 parallel async queries at the the service // in waves of a 1000 queries at a time. try { TestInit(true, true); int cQueries = 100000; int cWave = 1000; int cCompleted = 0; bool fail = false; ElapsedTimer timer = new ElapsedTimer(); double rate; for (int i = 0; i < cQueries / cWave; i++) { cCompleted = 0; timer.Start(); for (int j = 0; j < cWave; j++) { client.BeginIPToGeoFix(testIP, ar => { var c = Interlocked.Increment(ref cCompleted); try { VerifyTestFix(client.EndIPToGeoFix(ar)); } catch { fail = true; } if (cCompleted == cWave) { timer.Stop(); } }, null); } Helper.WaitFor(() => cCompleted == cWave, TimeSpan.FromSeconds(60)); } rate = cQueries / timer.ElapsedTime.TotalSeconds; Debug.WriteLine("{0} seconds elapsed for {1} queries", timer.ElapsedTime, cQueries); Debug.WriteLine("Query Rate: {0}/sec", rate); if (fail) { Assert.Fail("One or more of the query operations failed."); } } finally { TestCleanup(); } }
private async void BtnPrepare_OnClick(object sender, RoutedEventArgs e) { if (dgUSB.SelectedItems.Count != 1) { MessageBox.Show(Localization.GetString("Global", 69), Localization.GetString("Global", 68)); return; } var usb = (USBDrive)dgUSB.SelectedItems[0]; if (usb.LargerThan32Gb) { MessageBox.Show(Localization.GetString("FrmUSBPrep", 23), Localization.GetString("FrmUSBPrep", 24)); return; } var MBR = MessageBoxResult.None; if (usb.BootRecord == BootRecord.MBR && rbUEFI.IsChecked == true) { MBR = MessageBox.Show( Localization.GetString("FrmUSBPrep", 35) + " " + Localization.GetString("Global", 55) + "\n\n[" + Localization.GetString("FrmUSBPrep", 34) + "]", Localization.GetString("FrmUSBPrep", 25), MessageBoxButton.YesNo); } if (usb.BootRecord == BootRecord.GPT && rbBIOS.IsChecked == true) { MBR = MessageBox.Show( Localization.GetString("FrmUSBPrep", 36) + " " + Localization.GetString("Global", 55) + "\n\n[" + Localization.GetString("FrmUSBPrep", 34) + "]", Localization.GetString("FrmUSBPrep", 25), MessageBoxButton.YesNo); } if (MBR != MessageBoxResult.None && MBR != MessageBoxResult.Yes) { return; } Enable(false); watcher.Stop(); var elapsedTimer = new ElapsedTimer(ref txtTime); elapsedTimer.Start(); pbProgress.Value = 0; lblStatus.Text = Localization.GetString("FrmISOMaker", 18); var quickFormat = cbQuickFormat.IsChecked == true; var UEFI = rbUEFI.IsChecked == true; var newFormat = DriveFormat.FAT32; if (rbNTFS.IsChecked == true) { newFormat = DriveFormat.NTFS; } var result = string.Empty; usb.PropertyChanged += delegate(object o, PropertyChangedEventArgs args) { lblStatus.UpdateText(args.PropertyName); }; watcher.Stop(); await Task.Factory.StartNew(() => { if (UEFI) { result = usb.PrepareUSB_GPT(quickFormat, pbProgress); } else { result = usb.PrepareUSB_MBR(quickFormat, newFormat, pbProgress); } }).ContinueWith(delegate { elapsedTimer.Stop(); pbProgress.Value = 100; lblStatus.Text = "Done"; }, TaskScheduler.FromCurrentSynchronizationContext()); Scan(); }
private void StopElaspedTimer() { GameObject go = GameObject.Find("ElapsedTimer"); _elapsedTimer = (ElapsedTimer) go.GetComponent(typeof(ElapsedTimer)); _elapsedTimer.Stop(); }
public void IPToGeocode_UpdateData_WithQueries() { // Blast 100,000 parallel async queries at the the service // in waves of a 1000 queries at a time and during the middle of // this activity, prod the server to download a new database file // as often as possible. try { TestInit(true, true); int cQueries = 100000; int cWave = 1000; int cCompleted = 0; bool fail = false; ElapsedTimer timer = new ElapsedTimer(); int lastUpdateCount = 0; double rate; for (int i = 0; i < cQueries / cWave; i++) { cCompleted = 0; timer.Start(); for (int j = 0; j < cWave; j++) { client.BeginIPToGeoFix(testIP, ar => { var c = Interlocked.Increment(ref cCompleted); try { VerifyTestFix(client.EndIPToGeoFix(ar)); } catch { fail = true; } if (cCompleted == cWave) { timer.Stop(); } }, null); } Helper.WaitFor(() => cCompleted == cWave, TimeSpan.FromSeconds(60)); // Prod the server the first time through and then after the server // has completed downloading the previous update. if (i == 0 || server.IPGeocoder.UpdateCount > lastUpdateCount) { var oldDate = new DateTime(2000, 1, 1); try { File.SetCreationTimeUtc(IPGeocoder.DataPath, oldDate); File.SetLastWriteTimeUtc(IPGeocoder.DataPath, oldDate); File.SetLastAccessTimeUtc(IPGeocoder.DataPath, oldDate); lastUpdateCount = server.IPGeocoder.UpdateCount; server.IPGeocoder.PollForUpdates(); } catch (IOException) { // I'm going to ignore I/O errors because there's a decent // chance that the data file may be open in the geocoder's // download thread. } } } rate = cQueries / timer.ElapsedTime.TotalSeconds; Debug.WriteLine("{0} seconds elapsed for {1} queries", timer.ElapsedTime, cQueries); Debug.WriteLine("Query Rate: {0}/sec", rate); if (fail) { Assert.Fail("One or more of the query operations failed."); } } finally { server.IPGeocoder.StopImmediately = true; TestCleanup(); } }
/// <summary> /// Add the number of bytes and time to the counter /// </summary> /// <param name="fileCount">The number of files the bytes are spread over.</param> /// <param name="skipped">Number of files skipped</param> /// <param name="unknownSize">Number of files whose size could not be determined.</param> /// <param name="failed">Nnumber of files that failed to transit.</param> /// <param name="bytes">Number of bytes for this call</param> /// <param name="time">Elapsed time for this call</param> public void Add(long fileCount, long skipped, long unknownSize, long failed, long bytes, ElapsedTimer time) { m_filecount.Add(fileCount); m_skipped.Add(skipped); m_unknown.Add(unknownSize); m_count.Add(); m_bytes.Add(bytes); m_time.Add(time.TotalMilliseconds); m_failed.Add(failed); }
public void SwitchConnection_BlastEvents() { // Simulate the blasting of events from the switch to the remote connection. var handlerDone = false; var cEventsReceived = 0; var connectHandler = new EventHandler <SwitchInboundConnectionArgs>( (s, a) => { a.StartConnectionThread = false; Helper.EnqueueAction(() => { SwitchConnection serverConnection = a.Connection; AuthHandshake(serverConnection, false); serverConnection.StartThread(); Helper.EnqueueAction( () => { for (int i = 0; i < TransactionCount; i++) { SendEvent(serverConnection, SwitchEventCode.Heartbeat, "Hello World!", new NameValue("Foo", "Bar")); } }); Helper.WaitFor(() => cEventsReceived == TransactionCount, Timeout); serverConnection.Close(); handlerDone = true; }); }); SwitchConnection.InboundConnection += connectHandler; try { SwitchConnection.SendBufferSize = SwitchConnection.ReceiveBufferSize = SocketBufferSize; SwitchConnection.StartListener(binding, 10); var connection = new SwitchConnection(binding, SwitchConnection.DefaultPassword); var elapsedTimer = new ElapsedTimer(); connection.EventReceived += (s, a) => { if (a.EventCode == SwitchEventCode.Heartbeat && a.ContentType == "text" && a.ContentText == "Hello World!") { Interlocked.Increment(ref cEventsReceived); } }; connection.Connect(); elapsedTimer.Start(); Helper.WaitFor(() => handlerDone, Timeout); elapsedTimer.Stop(); var rate = cEventsReceived / elapsedTimer.ElapsedTime.TotalSeconds; Debug.WriteLine(string.Format("Transaction Rate: {0}/sec", rate)); } finally { SwitchConnection.ResetGlobals(); SwitchConnection.InboundConnection -= connectHandler; SwitchConnection.StopListener(); } }
public void SwitchConnection_BlastBoth() { // Simulate the blasting of events from the switch to the remote connection // and commands from the remote machine to the switch. var handlerDone = false; var cCommandsReceived = 0; var cCommandsExecuted = 0; var cEventsReceived = 0; var connectHandler = new EventHandler <SwitchInboundConnectionArgs>( (s, a) => { a.StartConnectionThread = false; Helper.EnqueueAction(() => { SwitchConnection serverConnection = a.Connection; serverConnection.CommandReceived += (s1, a1) => { if (a1.CommandText == "sendevent HEARTBEAT" && Helper.ASCIIEncoding.GetString(a1.Content) == "Hello World!" && a1.Properties["Foo"] == "Bar") { Interlocked.Increment(ref cCommandsReceived); } }; AuthHandshake(serverConnection, false); serverConnection.StartThread(); Helper.EnqueueAction( () => { for (int i = 0; i < TransactionCount; i++) { SendEvent(serverConnection, SwitchEventCode.Heartbeat, "Hello World!", new NameValue("Foo", "Bar")); } }); Helper.WaitFor(() => cCommandsReceived == TransactionCount && cCommandsExecuted == TransactionCount && cEventsReceived == TransactionCount, Timeout); serverConnection.Close(); handlerDone = true; }); }); SwitchConnection.InboundConnection += connectHandler; try { SwitchConnection.SendBufferSize = SwitchConnection.ReceiveBufferSize = SocketBufferSize; SwitchConnection.StartListener(binding, 10); var connection = new SwitchConnection(binding, SwitchConnection.DefaultPassword); var elapsedTimer = new ElapsedTimer(); connection.EventReceived += (s, a) => { if (a.EventCode == SwitchEventCode.Heartbeat && a.ContentType == "text" && a.ContentText == "Hello World!") { Interlocked.Increment(ref cEventsReceived); } }; connection.Connect(); elapsedTimer.Start(); for (int i = 0; i < TransactionCount; i++) { var properties = new ArgCollection(ArgCollectionType.Unconstrained); properties["Foo"] = "Bar"; connection.SendEvent(SwitchEventCode.Heartbeat, properties, "Hello World!"); Interlocked.Increment(ref cCommandsExecuted); } Helper.WaitFor(() => handlerDone, Timeout); elapsedTimer.Stop(); var rate = (cCommandsReceived + cEventsReceived) / elapsedTimer.ElapsedTime.TotalSeconds; Debug.WriteLine(string.Format("Transaction Rate: {0}/sec", rate)); } finally { SwitchConnection.ResetGlobals(); SwitchConnection.InboundConnection -= connectHandler; SwitchConnection.StopListener(); } }
/// <summary> /// Add the amount and the time to the counter /// </summary> /// <param name="amount">The amount to add for this call</param> /// <param name="time">Elapsed time for this call</param> public void Add(double amount, ElapsedTimer time) { m_count.Add(); m_number.Add(amount); m_time.Add(time.TotalMilliseconds); }