Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace BenchmarkLab {
- class TypeTestsList : Benchmark {
- public TypeTestsList(Object type) {
- if (type is int) {
- typeTestsList.Add(() => {
- int a = 2, b = 2, c = 1;
- for (int i = 0; i < NumOfIterations; ++i) { a = b + c; b = a + c; c = a + b; }
- });
- typeTestsList.Add(() => {
- int a = 2, b = 2, c = 1;
- for (int i = 0; i < NumOfIterations; ++i) { a = b - c; b = a - c; c = a - b; }
- });
- typeTestsList.Add(() => {
- int a = 2, b = 2, c = 1;
- for (int i = 0; i < NumOfIterations; ++i) { a = b * c; b = a * c; c = a * b; }
- });
- typeTestsList.Add(() => {
- int a = 2, b = 2, c = 1;
- for (int i = 0; i < NumOfIterations; ++i) { a = b / c; b = a / c; c = a / b; }
- });
- } else if (type is uint) {
- typeTestsList.Add(() => {
- uint a = 2, b = 2, c = 1;
- for (int i = 0; i < NumOfIterations; ++i) { a = b + c; b = a + c; c = a + b; }
- });
- typeTestsList.Add(() => {
- uint a = 2, b = 2, c = 1;
- for (int i = 0; i < NumOfIterations; ++i) { a = b - c; b = a - c; c = a - b; }
- });
- typeTestsList.Add(() => {
- uint a = 2, b = 2, c = 1;
- for (int i = 0; i < NumOfIterations; ++i) { a = b * c; b = a * c; c = a * b; }
- });
- typeTestsList.Add(() => {
- uint a = 2, b = 2, c = 1;
- for (int i = 0; i < NumOfIterations; ++i) { a = b / c; b = a / c; c = a / b; }
- });
- } else if (type is long) {
- typeTestsList.Add(() => {
- long a = 2, b = 2, c = 1;
- for (int i = 0; i < NumOfIterations; ++i) { a = b + c; b = a + c; c = a + b; }
- });
- typeTestsList.Add(() => {
- long a = 2, b = 2, c = 1;
- for (int i = 0; i < NumOfIterations; ++i) { a = b - c; b = a - c; c = a - b; }
- });
- typeTestsList.Add(() => {
- long a = 2, b = 2, c = 1;
- for (int i = 0; i < NumOfIterations; ++i) { a = b * c; b = a * c; c = a * b; }
- });
- typeTestsList.Add(() => {
- long a = 2, b = 2, c = 1;
- for (int i = 0; i < NumOfIterations; ++i) { a = b / c; b = a / c; c = a / b; }
- });
- } else if (type is ulong) {
- typeTestsList.Add(() => {
- ulong a = 2, b = 2, c = 1;
- for (int i = 0; i < NumOfIterations; ++i) { a = b + c; b = a + c; c = a + b; }
- });
- typeTestsList.Add(() => {
- ulong a = 2, b = 2, c = 1;
- for (int i = 0; i < NumOfIterations; ++i) { a = b - c; b = a - c; c = a - b; }
- });
- typeTestsList.Add(() => {
- ulong a = 2, b = 2, c = 1;
- for (int i = 0; i < NumOfIterations; ++i) { a = b * c; b = a * c; c = a * b; }
- });
- typeTestsList.Add(() => {
- ulong a = 2, b = 2, c = 1;
- for (int i = 0; i < NumOfIterations; ++i) { a = b / c; b = a / c; c = a / b; }
- });
- } else if (type is float) {
- typeTestsList.Add(() => {
- float a = 2f, b = 2f, c = 1f;
- for (int i = 0; i < NumOfIterations; ++i) { a = b + c; b = a + c; c = a + b; }
- });
- typeTestsList.Add(() => {
- float a = 2f, b = 2f, c = 1f;
- for (int i = 0; i < NumOfIterations; ++i) { a = b - c; b = a - c; c = a - b; }
- });
- typeTestsList.Add(() => {
- float a = 2f, b = 2f, c = 1f;
- for (int i = 0; i < NumOfIterations; ++i) { a = b * c; b = a * c; c = a * b; }
- });
- typeTestsList.Add(() => {
- float a = 2f, b = 2f, c = 1f;
- for (int i = 0; i < NumOfIterations; ++i) { a = b / c; b = a / c; c = a / b; }
- });
- } else if (type is double) {
- typeTestsList.Add(() => {
- double a = 2d, b = 2d, c = 1d;
- for (int i = 0; i < NumOfIterations; ++i) { a = b + c; b = a + c; c = a + b; }
- });
- typeTestsList.Add(() => {
- double a = 2d, b = 2d, c = 1d;
- for (int i = 0; i < NumOfIterations; ++i) { a = b - c; b = a - c; c = a - b; }
- });
- typeTestsList.Add(() => {
- double a = 2d, b = 2d, c = 1d;
- for (int i = 0; i < NumOfIterations; ++i) { a = b * c; b = a * c; c = a * b; }
- });
- typeTestsList.Add(() => {
- double a = 2d, b = 2d, c = 1d;
- for (int i = 0; i < NumOfIterations; ++i) { a = b / c; b = a / c; c = a / b; }
- });
- } else
- throw new System.ArgumentException("Unknown type of argument!");
- }
- public List<Action> typeTestsList { get; private set; } = new List<Action>();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment