samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sat Nov 24, 2007 10:31 am Post subject: Looping Through a million classes in an array |
|
|
People, I have found my method of getting the opcode.
I ran a test:
| Code: |
Toy[] toys = new Toy[1000000];
//init
Console.WriteLine("Init'ing...");
for (Int64 i = 0; i < toys.Length; i ++)
{
toys[i] = new Toy();
toys[i].Lul = "number " + i.ToString();
toys[i].Lol = i;
}
Console.WriteLine("Now we start");
DateTime begin = DateTime.Now;
Console.WriteLine(begin.ToString());
Toy t = Array.Find<Toy>(toys, mypred);
Console.WriteLine(t.Lol);
Console.WriteLine(t.Lul);
DateTime end = DateTime.Now;
Console.WriteLine(end.ToString());
TimeSpan elapsed = end.Subtract(begin);
Console.WriteLine(elapsed.ToString());
Console.ReadLine();
}
private static bool mypred(Toy t)
{
return t.Lul == "number 999999";
}
}
public class Toy
{
public Int64 Lol = 0;
public string Lul = "";
}
|
The result was this:
| Code: |
Init'ing...
Now we start
11/24/2007 10:26:00 AM
999999
number 999999
11/24/2007 10:26:00 AM
00:00:00.0781250
|
So that's an elapsed time of
78 thousandths of a second, to loop through a million classes in an array.
Some simple math here,
| Code: |
0.078 / 1000000 = 0.000000078
|
So that's... 78 one-hundred-thousandths of a second per one element in an array.
=D
|
|