public void AtomicInt64SupportsGetAndAddNegativesMultiThreaded() { const long expected = 1000; var i = new AtomicInt64(); System.Threading.Tasks.Parallel.For(0, expected, j => i.GetAndAdd(1)); Assert.AreEqual(expected, (long)i); Assert.AreEqual(expected, i.Value); }
public void AtomicInt64SupportsGetAndAdd() { const long expected = 1000; var i = new AtomicInt64(); for (int j = 0; j < expected; j++) { i.GetAndAdd(1); } Assert.AreEqual(expected, (long)i); Assert.AreEqual(expected, i.Value); }
public void AtomicInt64SupportsGetAndAddNegatives() { const long expected = 0; var i = new AtomicInt64(); i.GetAndSet(1000); for (int j = 0; j < 1000; j++) { i.GetAndAdd(-1); } Assert.AreEqual(expected, (long)i); Assert.AreEqual(expected, i.Value); }
public void Run() { var sw = new System.Diagnostics.Stopwatch(); sw.Start(); for (int i = 0; i < _numIters; ++i) { long start = sw.ElapsedMilliseconds; CombinedFacetAccessible combined1 = new CombinedFacetAccessible(_fspec, _list1); // CombinedFacetAccessible combined2 = new CombinedFacetAccessible(_fspec, _list2); IEnumerable <BrowseFacet> facets1 = combined1.GetFacets(); //IEnumerable<BrowseFacet> facets2 = combined2.GetFacets(); long end = sw.ElapsedMilliseconds; _timeCounter.GetAndAdd(end - start); } }