|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace GenericArithmetic {
public partial class SpeedTest : Form {
public SpeedTest() {
InitializeComponent();
}
private void ClassConstraintButton_Click(object sender, EventArgs e) {
Random random = new Random(DateTime.Now.Millisecond);
SummableListC<IntMathClass> list = new SummableListC<IntMathClass>();
for (int i = 0; i < (int)numericUpDown1.Value; i++) {
list.Add(random.Next(1000));
}
DateTime startTime = DateTime.Now;
int sum = list.Sum();
int average = list.Average();
DateTime endTime = DateTime.Now;
TimeSpan difference = endTime - startTime;
ClassConstraintTextBox.Text = string.Format("{0:0.00}", difference.TotalMilliseconds);
}
private void InterfaceConstraintButton_Click(object sender, EventArgs e) {
Random random = new Random(DateTime.Now.Millisecond);
SummableListI<IntMathI> list = new SummableListI<IntMathI>();
for (int i = 0; i < (int)numericUpDown1.Value; i++) {
list.Add(random.Next(1000));
}
DateTime startTime = DateTime.Now;
int sum = list.Sum();
int average = list.Average();
DateTime endTime = DateTime.Now;
TimeSpan difference = endTime - startTime;
InterfaceConstraintTextBox.Text = string.Format("{0:0.00}", difference.TotalMilliseconds);
}
private void CalcutilButton_Click(object sender, EventArgs e) {
Random random = new Random(DateTime.Now.Millisecond);
SummableListU<int> list = new SummableListU<int>();
for (int i = 0; i < (int)numericUpDown1.Value; i++) {
list.Add(random.Next(1000));
}
DateTime startTime = DateTime.Now;
int sum = list.Sum();
int average = list.Average();
DateTime endTime = DateTime.Now;
TimeSpan difference = endTime - startTime;
CalcUtilTextBox.Text = string.Format("{0:0.00}", difference.TotalMilliseconds);
}
private void LinqExpressionButton_Click(object sender, EventArgs e) {
Random random = new Random(DateTime.Now.Millisecond);
SummableListL<int> list = new SummableListL<int>();
for (int i = 0; i < (int)numericUpDown1.Value; i++) {
list.Add(random.Next(1000));
}
DateTime startTime = DateTime.Now;
int sum = list.Sum();
int average = list.Average();
DateTime endTime = DateTime.Now;
TimeSpan difference = endTime - startTime;
LinqExpressionTextBox.Text = string.Format("{0:0.00}", difference.TotalMilliseconds);
}
private void MiscUtilButton_Click(object sender, EventArgs e) {
Random random = new Random(DateTime.Now.Millisecond);
SummableListM<int> list = new SummableListM<int>();
for (int i = 0; i < (int)numericUpDown1.Value; i++) {
list.Add(random.Next(1000));
}
DateTime startTime = DateTime.Now;
int sum = list.Sum();
int average = list.Average();
DateTime endTime = DateTime.Now;
TimeSpan difference = endTime - startTime;
MiscUtilTextBox.Text = string.Format("{0:0.00}", difference.TotalMilliseconds);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.