Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using BenchmarkDotNet.Attributes;
- namespace Task4C
- {
- [MemoryDiagnoser]
- public class BubbleSort
- {
- public static int[] _numbers;
- [Benchmark]
- public void Sort()
- {
- int temp;
- for (int i = 0; i < _numbers.Length; i++)
- {
- for (int j = i + 1; j < _numbers.Length; j++)
- {
- if (_numbers[i] > _numbers[j])
- {
- temp = _numbers[i];
- _numbers[i] = _numbers[j];
- _numbers[j] = temp;
- }
- }
- }
- }
- [IterationSetup]
- public void MakeArray()
- {
- var number = new Random();
- var arr = new int[2000];
- for (var i = 0; i < arr.Length; i++) {
- arr[i] = number.Next();
- }
- _numbers = arr;
- }
- }
- }
Add Comment
Please, Sign In to add comment