public void Run() { try { barrier.Await(); long i = iters; int y = 0; int succ = 0; while (i > 0) { for (int k = 0; k < CASLoops.innerPerOuter; ++k) { int x = obj.get_Renamed(); int z = y + LoopHelpers.compute6(x); if (obj.compareAndSet(x, z)) { ++succ; } y = LoopHelpers.compute7(z); } i -= CASLoops.innerPerOuter; } CASLoops.sum.AddDeltaAndReturnPreviousValue(obj.get_Renamed()); CASLoops.successes.AddDeltaAndReturnPreviousValue(succ); barrier.Await(); } catch (System.Exception ie) { return; } }
internal static void report(System.String tag, long runtime, long basetime, int nthreads, long iters) { System.Console.Out.Write(tag); long t = (runtime - basetime) / iters; if (nthreads > NCPUS) { t = t * NCPUS / nthreads; } System.Console.Out.Write(LoopHelpers.rightJustify(t)); //UPGRADE_WARNING: Data types in Visual C# might be different. Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'" double secs = (double)(runtime) / 1000000000.0; System.Console.Out.WriteLine("\t " + secs + "s run time"); }
public void OrderedArrayTest() { var l = new[] { new ScriptInfo() { ScriptId = "1", NeedsMainThread = true, ExecTime = new TimeSpan(), ScriptLanguage = ScriptLanguage.Handlebar }, new ScriptInfo() { ScriptId = "2", NeedsMainThread = false, ExecTime = new TimeSpan(), ScriptLanguage = ScriptLanguage.Handlebar }, new ScriptInfo() { ScriptId = "3", NeedsMainThread = false, ExecTime = new TimeSpan(), ScriptLanguage = ScriptLanguage.Cs }, new ScriptInfo() { ScriptId = "4", NeedsMainThread = true, ExecTime = new TimeSpan(), ScriptLanguage = ScriptLanguage.Cs }, }; Assert.AreEqual("2314", LoopHelpers.OrderedList(l, "+NeedsMainThread,-ExecTime,+ScriptLanguage").Aggregate("", (S, E) => S + ((ScriptInfo)E).ScriptId)); }
public void Run() { try { barrier.Await(); long iters = 0; int y = 0; int succ = 0; do { int i = CASLoops.loopsPerTimeCheck; while (i > 0) { for (int k = 0; k < CASLoops.innerPerOuter; ++k) { int x = obj.get_Renamed(); int z = y + LoopHelpers.compute6(x); if (obj.compareAndSet(x, z)) { ++succ; } y = LoopHelpers.compute7(z); } i -= CASLoops.innerPerOuter; } iters += CASLoops.loopsPerTimeCheck; }while ((System.DateTime.Now.Ticks - 621355968000000000) / 10000 < endTime); CASLoops.totalIters.AddDeltaAndReturnPreviousValue(iters); CASLoops.sum.AddDeltaAndReturnPreviousValue(obj.get_Renamed()); CASLoops.successes.AddDeltaAndReturnPreviousValue(succ); barrier.Await(); } catch (System.Exception ie) { return; } }
internal static void oneRun(int i, long iters, bool print) { if (print) { System.Console.Out.WriteLine("threads : " + i + " base iters per thread per run : " + LoopHelpers.rightJustify(loopIters[i])); } long ntime = runNonAtomic(i, iters); if (print) { report("Base : ", ntime, ntime, i, iters); } //UPGRADE_TODO: Method 'java.lang.Thread.sleep' was converted to 'System.Threading.Thread.Sleep' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javalangThreadsleep_long'" System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 100L)); long atime = runAtomic(i, iters); if (print) { report("Atomic CAS : ", atime, ntime, i, iters); } //UPGRADE_TODO: Method 'java.lang.Thread.sleep' was converted to 'System.Threading.Thread.Sleep' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javalangThreadsleep_long'" System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 100L)); // long gtime = runUpdaterAtomic(i, iters); // if (print) // report("Updater CAS : ", gtime, ntime, i, iters); // Thread.sleep(100L); long vtime = runVolatile(i, iters); if (print) { report("Volatile : ", vtime, ntime, i, iters); } //UPGRADE_TODO: Method 'java.lang.Thread.sleep' was converted to 'System.Threading.Thread.Sleep' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javalangThreadsleep_long'" System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 100L)); long stime = runSynched(i, iters); if (print) { report("Synchronized: ", stime, ntime, i, iters); } //UPGRADE_TODO: Method 'java.lang.Thread.sleep' was converted to 'System.Threading.Thread.Sleep' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javalangThreadsleep_long'" System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 100L)); if (!includeLocks) { return; } long mtime = runLocked(i, iters); if (print) { report("Mutex : ", mtime, ntime, i, iters); } //UPGRADE_TODO: Method 'java.lang.Thread.sleep' was converted to 'System.Threading.Thread.Sleep' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javalangThreadsleep_long'" System.Threading.Thread.Sleep(new System.TimeSpan((System.Int64) 10000 * 100L)); }