//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldRegisterConcurrentAllocationsAndDeallocations() throws Throwable
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldRegisterConcurrentAllocationsAndDeallocations()
        {
            // given
            ThreadSafePeakMemoryAllocationTracker tracker = new ThreadSafePeakMemoryAllocationTracker(GlobalMemoryTracker.Instance);
            Race race = new Race();

            race.AddContestants(10, () =>
            {
                for (int i = 1; i < 100; i++)
                {
                    tracker.Allocated(i);
                    assertThat(tracker.UsedDirectMemory(), greaterThan(0L));
                }
                for (int i = 1; i < 100; i++)
                {
                    assertThat(tracker.UsedDirectMemory(), greaterThan(0L));
                    tracker.Deallocated(i);
                }
            }, 1);

            // when
            race.Go();

            // then
            assertEquals(0, tracker.UsedDirectMemory());
        }
Exemple #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void tryOnce(final org.neo4j.kernel.internal.GraphDatabaseAPI db, final org.neo4j.graphdb.Node node) throws Throwable
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        private void TryOnce(GraphDatabaseAPI db, Node node)
        {
            Race race = (new Race()).withRandomStartDelays();

            race.AddContestants(Runtime.Runtime.availableProcessors(), () =>
            {
                using (Transaction ignored = Db.beginTx())
                {
                    assertEquals(_relCount, count(node.Relationships));
                }
            });
            race.Go();
        }