static void Main(string[] args) { Console.Write("{0}{1}", "\n Time Parsing Operations ", "\n =========================\n" ); OpTimer ot = new OpTimer(); ot.Verbose = false; string fileName = "../../Test.cs"; ot.ParseFile(fileName); HiResTimer hrt = new HiResTimer(); hrt.Start(); int N = 1000; for (int i = 0; i < N; ++i) { ot.HashLookUp("class"); } hrt.Stop(); ulong lookUpTime = hrt.ElapsedMicroseconds; Console.Write("\n {0} lookups took {1} microseconds", N, lookUpTime); Console.Write("\n\n"); ot.showTable(); Console.Write("\n\n"); }
static void main(string[] args) { HiResTimer hr = new HiResTimer(); hr.Start(); hr.Stop(); Console.Write("time elapsed: " + hr.ElapsedMicroseconds.ToString()); }
//----< initialize Sender >-------------------------------------- public Sender() { sndBlockingQ = new BlockingQueue<Message>(); sndThrd = new Thread(ThreadProc); sndThrd.IsBackground = true; sndThrd.Start(); block = new byte[BlockSize]; hrt = new HRTimer.HiResTimer(); }
static void Main(string[] args) { HiResTimer hrt = new HiResTimer(); hrt.Start(); int sum = 0; int N = 1000; for(int i=0; i<N; ++i) { sum += (i+1); } hrt.Stop(); Console.Write( "\n after {0} iterations, sum = {1}, computed in {2} microSecs\n", N, sum, hrt.ElapsedMicroseconds ); }
static void Main(string[] args) { HiResTimer hrt = new HiResTimer(); hrt.Start(); int sum = 0; int N = 1000; for (int i = 0; i < N; ++i) { sum += (i + 1); } hrt.Stop(); Console.Write( "\n after {0} iterations, sum = {1}, computed in {2} microSecs\n", N, sum, hrt.ElapsedMicroseconds ); }
// //----< parse file into identifiers and store in Hashtable >------- public void ParseFile(string fileName) { HiResTimer total = new HiResTimer(); HiResTimer open = new HiResTimer(); HiResTimer parse = new HiResTimer(); try { total.Start(); open.Start(); StreamReader fs = new StreamReader(fileName); open.Stop(); openTime = open.ElapsedMicroseconds; parse.Start(); int size = 0; string line; while ((line = fs.ReadLine()) != null) { string[] tokens = line.Split(); foreach (string token in tokens) { if (token == "\n" | token.Length == 0) { continue; } if (Verbose) { Console.Write("\n {0}", token); } string tok, compositeToken = token; while (compositeToken != "") { tok = extractIdent(ref compositeToken); if (tok == "") { continue; } if (Verbose) { Console.Write("\n {0}", tok); } if (table.Contains(tok)) { table[tok] = 1 + (int)table[tok]; } else { table[tok] = 1; size += tok.Length; } } } } parse.Stop(); parseTime = parse.ElapsedMicroseconds; total.Stop(); totalTime = total.ElapsedMicroseconds; // Console.Write("\n Open time: {0} microsec", openTime); Console.Write("\n Parse time: {0} microsec", parseTime); Console.Write("\n total time: {0} microsec", totalTime); Console.Write("\n Hash size: {0} bytes", size); } catch { Console.Write("\n Could not open file \"{0}\"\n\n", fileName); } }
//----< Entry point into Read Client >------------------------------- static void Main(string[] args) { ReadClient clnt = new ReadClient(); bool success = clnt.ProcessCommandArgsAndFile(clnt, args); if (!success) return; HiResTimer timer = new HiResTimer(); timer.Start(); List<Message> messageList = clnt.ProcessXML("MessagePrototype.xml"); clnt.latencyTimers.Add(new HiResTimer()); clnt.latencyValues.Add(new ulong()); foreach (Message message in messageList) { if (clnt.sndr.sendMessage(message)) { HiResTimer temp = new HiResTimer(); temp.Start(); clnt.latencyTimers.Add(temp); clnt.latencyValues.Add(new ulong()); Console.Write("\n Request ID: {0}\n", message.messageID); Console.WriteLine(message.content); } else { Console.Write("\n could not connect in {0} attempts", clnt.sndr.MaxConnectAttempts); clnt.sndr.shutdown(); clnt.rcvr.shutDown(); return; } } timer.Stop(); Console.WriteLine("\n ====================================================="); Console.WriteLine("\n Total time to send all the messages: {0} microseconds", timer.ElapsedMicroseconds); Console.WriteLine("\n ====================================================="); Message msg = new Message(); msg.fromUrl = clnt.localUrl; msg.toUrl = clnt.remoteUrl; msg.content = "done"; clnt.sndr.sendMessage(msg); while(true) { if (clnt.rcvCount == messageList.Count()) { Thread.Sleep(500); clnt.performanceAnalysis(); break; } } Util.waitForUser(); clnt.rcvr.shutDown(); clnt.sndr.shutdown(); Console.Write("\n\n"); }
static void Main(string[] args) { Console.Write("{0}{1}", "\n Time Parsing Operations ", "\n =========================\n" ); HiResTimer hrt = new HiResTimer(); hrt.Start(); int N = 1000; for (int i = 0; i < N; ++i) Console.WriteLine("\n " + i); hrt.Stop(); ulong lookUpTime = hrt.ElapsedMicroseconds; Console.Write("\n {0} for loop took {1} microseconds", N, lookUpTime); Console.Write("\n\n"); Console.Write("\n\n"); }
StreamService() { block = new byte[BlockSize]; hrt = new HRTimer.HiResTimer(); }
static void Main(string[] args) { Console.Write("{0}{1}", "\n Time Parsing Operations ", "\n =========================\n" ); OpTimer ot = new OpTimer(); ot.Verbose = false; string fileName = "../../Test.cs"; ot.ParseFile(fileName); HiResTimer hrt = new HiResTimer(); hrt.Start(); int N = 1000; for(int i=0; i<N; ++i) ot.HashLookUp("class"); hrt.Stop(); ulong lookUpTime = hrt.ElapsedMicroseconds; Console.Write("\n {0} lookups took {1} microseconds",N,lookUpTime); Console.Write("\n\n"); ot.showTable(); Console.Write("\n\n"); }
// //----< parse file into identifiers and store in Hashtable >------- public void ParseFile(string fileName) { HiResTimer total = new HiResTimer(); HiResTimer open = new HiResTimer(); HiResTimer parse = new HiResTimer(); try { total.Start(); open.Start(); StreamReader fs = new StreamReader(fileName); open.Stop(); openTime = open.ElapsedMicroseconds; parse.Start(); int size = 0; string line; while((line = fs.ReadLine()) != null) { string[] tokens = line.Split(); foreach(string token in tokens) { if(token == "\n" | token.Length == 0) continue; if(Verbose) Console.Write("\n {0}",token); string tok, compositeToken = token; while(compositeToken != "") { tok = extractIdent(ref compositeToken); if(tok == "") continue; if(Verbose) Console.Write("\n {0}",tok); if(table.Contains(tok)) table[tok] = 1 + (int)table[tok]; else { table[tok] = 1; size += tok.Length; } } } } parse.Stop(); parseTime = parse.ElapsedMicroseconds; total.Stop(); totalTime = total.ElapsedMicroseconds; // Console.Write("\n Open time: {0} microsec",openTime); Console.Write("\n Parse time: {0} microsec",parseTime); Console.Write("\n total time: {0} microsec",totalTime); Console.Write("\n Hash size: {0} bytes",size); } catch { Console.Write("\n Could not open file \"{0}\"\n\n",fileName); } }