📄 form1.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Generics
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void RegularClick(object sender, EventArgs e)
{
// Define the number of values to add and remove
int iterations = 10000000; // 10,000,000
// Create an instance of RegularStack and initialise it
RegularStack s = new RegularStack(iterations);
// Note the start time
DateTime start = DateTime.Now;
// Push the values onto the stack
for (int f = 0; f < iterations; ++f)
s.Push(f);
// Pop the values off the stack
for (int f = 0; f < iterations; ++f)
s.Pop();
// Compute the time taken to complete the test
float ticks = DateTime.Now.Ticks - start.Ticks;
float duration = ticks / TimeSpan.TicksPerSecond;
// Display the duration to the user
MessageBox.Show("Duration = "
+ String.Format("{0:#0.0000}", duration));
}
private void GenericClick(object sender, EventArgs e)
{
// Define the number of values to add and remove
int iterations = 10000000; // 10,000,000
// Create an instance of GenericStack and initialise it
GenericStack<int> s = new GenericStack<int>(iterations);
// Note the start time
DateTime start = DateTime.Now;
// Push the values onto the stack
for (int f = 0; f < iterations; ++f)
s.Push(f);
// Pop the values off the stack
for (int f = 0; f < iterations; ++f)
s.Pop();
// Compute the time taken to complete the test
float ticks = DateTime.Now.Ticks - start.Ticks;
float duration = ticks / TimeSpan.TicksPerSecond;
// Display the duration to the user
MessageBox.Show("Duration = "
+ String.Format("{0:#0.0000}", duration));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -