Exemple #1
0
        private IList <ParallelTestData> SplitData(IEnumerable <TestData> input, int currentNumberOfTransactions, int currentNumberOfItemsPerTransaction, int numberOfThreads)
        {
            var data = new ConcurrentQueue <TestData>(input);

            Debug.Assert(data.Count == currentNumberOfItemsPerTransaction * currentNumberOfTransactions);

            var results = new List <ParallelTestData>();

            var numberOfTransactionsPerThread = currentNumberOfTransactions / numberOfThreads;

            for (var i = 0; i < numberOfThreads; i++)
            {
                var actualNumberOfTransactionsPerThread = i < numberOfThreads - 1
                                                              ? numberOfTransactionsPerThread
                                                              : currentNumberOfTransactions - (i * numberOfTransactionsPerThread);

                var item = new ParallelTestData
                {
                    Queue = data,
                    ItemsPerTransaction  = currentNumberOfItemsPerTransaction,
                    NumberOfTransactions = actualNumberOfTransactionsPerThread
                };

                results.Add(item);
            }

            return(results);
        }
        private IList<ParallelTestData> SplitData(IEnumerable<TestData> input, int currentNumberOfTransactions, int currentNumberOfItemsPerTransaction, int numberOfThreads)
        {
            var data = new ConcurrentQueue<TestData>(input);
            Debug.Assert(data.Count == currentNumberOfItemsPerTransaction * currentNumberOfTransactions);

            var results = new List<ParallelTestData>();

            var numberOfTransactionsPerThread = currentNumberOfTransactions / numberOfThreads;

            for (var i = 0; i < numberOfThreads; i++)
            {
                var actualNumberOfTransactionsPerThread = i < numberOfThreads - 1
                                                              ? numberOfTransactionsPerThread
                                                              : currentNumberOfTransactions - (i * numberOfTransactionsPerThread);

                var item = new ParallelTestData
                               {
                                   Queue = data,
                                   ItemsPerTransaction = currentNumberOfItemsPerTransaction,
                                   NumberOfTransactions = actualNumberOfTransactionsPerThread
                               };

                results.Add(item);
            }

            return results;
        }