Пример #1
0
    // Use this for initialization
    void Start()
    {
        Stopwatch stp1 = new Stopwatch();
        Stopwatch stp2 = new Stopwatch();

        cInts = new ClassInts[size];
        sInts = new StructInts[size];

        stp1.Start();

        for (int i = 0; i < size; ++i)
        {
            cInts[i] = new ClassInts();
        }

        //for loop 1…
        for (int i = 0; i < size; i++)
        {
            RandomiseClass(cInts[i]);
        }

        stp1.Stop();
        print("stp1: " + stp1.Elapsed);

        stp2.Start();

        //for loop 2…
        for (int i = 0; i < size; i++)
        {
            RandomiseStruct(ref sInts[i]);
        }
        stp2.Stop();
        print("stp2: " + stp2.Elapsed);
    }
Пример #2
0
 void RandomiseClass(ClassInts c)
 {
     c.x = Random.Range(0, 100);
 }