Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.Windows.Forms;
- namespace ClickTest
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- ClickTest();
- MouseClickTest();
- ClickTest();
- MouseClickTest();
- }
- private void ClickTest()
- {
- Button[] buttons = CreateButtons(1000);
- Stopwatch timer = new Stopwatch();
- timer.Start();
- for (int i = 0; i < 1000; i++) buttons[i].Click += Form1_Click;
- timer.Stop();
- Console.WriteLine("Click: " + timer.ElapsedMilliseconds);
- }
- private void MouseClickTest()
- {
- Button[] buttons = CreateButtons(1000);
- Stopwatch timer = new Stopwatch();
- timer.Start();
- for (int i = 0; i < 1000; i++) buttons[i].MouseClick += Form1_MouseClick;
- timer.Stop();
- Console.WriteLine("MouseClick: " + timer.ElapsedMilliseconds);
- }
- private Button[] CreateButtons(int length)
- {
- Button[] buttons = new Button[length];
- for (int i = 0; i < length; i++) buttons[i] = new Button();
- return buttons;
- }
- private void Form1_Click(object sender, EventArgs e)
- {
- throw new NotImplementedException();
- }
- private void Form1_MouseClick(object sender, MouseEventArgs e)
- {
- throw new NotImplementedException();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement