<commit_before>﻿
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using Metrics.Core;
using Xunit;

namespace Metrics.Tests
{
    public class CounterTests
    {
        [Fact]
        public void CounterStartsFromZero()
        {
            new CounterMetric().Value.Should().Be(0L);
        }

        [Fact]
        public void CounterCanIncrement()
        {
            Counter counter = new CounterMetric();
            counter.Increment();
            counter.Value.Should().Be(1L);
        }

        [Fact]
        public void CounterCanIncrementWithValue()
        {
            Counter counter = new CounterMetric();
            counter.Increment(32L);
            counter.Value.Should().Be(32L);
        }

        [Fact]
        public void CounterCanIncrementMultipleTimes()
        {
            Counter counter = new CounterMetric();
            counter.Increment();
            counter.Increment();
            counter.Increment();
            counter.Value.Should().Be(3L);
        }

        [Fact]
        public void CounterCanDecrement()
        {
            Counter counter = new CounterMetric();
            counter.Decrement();
            counter.Value.Should().Be(-1L);
        }

        [Fact]
        public void CounterCanDecrementWithValue()
        {
            Counter counter = new CounterMetric();
            counter.Decrement(32L);
            counter.Value.Should().Be(-32L);
        }

        [Fact]
        public void CounterCanDecrementMultipleTimes()
        {
            Counter counter = new CounterMetric();
            counter.Decrement();
            counter.Decrement();
            counter.Decrement();
            counter.Value.Should().Be(-3L);
        }

        [Fact]
        public void CounterCanBeIncrementedOnMultipleThreads()
        {
            const int threadCount = 16;
            const long iterations = 1000 * 1000;

            Counter counter = new CounterMetric();

            List<Thread> threads = new List<Thread>();
            TaskCompletionSource<int> tcs = new TaskCompletionSource<int>();

            for (int i = 0; i < threadCount; i++)
            {
                threads.Add(new Thread(s =>
                {
                    tcs.Task.Wait();
                    for (long j = 0; j < iterations; j++)
                    {
                        counter.Increment();<commit_msg>reduce number of iterations in test<commit_after>﻿
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using Metrics.Core;
using Xunit;

namespace Metrics.Tests
{
    public class CounterTests
    {
        [Fact]
        public void CounterStartsFromZero()
        {
            new CounterMetric().Value.Should().Be(0L);
        }

        [Fact]
        public void CounterCanIncrement()
        {
            Counter counter = new CounterMetric();
            counter.Increment();
            counter.Value.Should().Be(1L);
        }

        [Fact]
        public void CounterCanIncrementWithValue()
        {
            Counter counter = new CounterMetric();
            counter.Increment(32L);
            counter.Value.Should().Be(32L);
        }

        [Fact]
        public void CounterCanIncrementMultipleTimes()
        {
            Counter counter = new CounterMetric();
            counter.Increment();
            counter.Increment();
            counter.Increment();
            counter.Value.Should().Be(3L);
        }

        [Fact]
        public void CounterCanDecrement()
        {
            Counter counter = new CounterMetric();
            counter.Decrement();
            counter.Value.Should().Be(-1L);
        }

        [Fact]
        public void CounterCanDecrementWithValue()
        {
            Counter counter = new CounterMetric();
            counter.Decrement(32L);
            counter.Value.Should().Be(-32L);
        }

        [Fact]
        public void CounterCanDecrementMultipleTimes()
        {
            Counter counter = new CounterMetric();
            counter.Decrement();
            counter.Decrement();
            counter.Decrement();
            counter.Value.Should().Be(-3L);
        }

        [Fact]
        public void CounterCanBeIncrementedOnMultipleThreads()
        {
            const int threadCount = 16;
            const long iterations = 1000 * 100;

            Counter counter = new CounterMetric();

            List<Thread> threads = new List<Thread>();
            TaskCompletionSource<int> tcs = new TaskCompletionSource<int>();

            for (int i = 0; i < threadCount; i++)
            {
                threads.Add(new Thread(s =>
                {
                    tcs.Task.Wait();
                    for (long j = 0; j < iterations; j++)
                    {
                        counter.Increment();
{'fraction_non_alphanumeric': 0.10165339865278629, 'fraction_numerical': 0.010002041232904674, 'mean_word_length': 1.55741127348643, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4101777', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1201, 'n_words': 266}