Показать сообщение отдельно
Старый 28.11.2011, 14:44   #31
johnk
Легенда
 
Регистрация: 01.10.2006
Сообщений: 3,705
Написано 296 полезных сообщений
(для 568 пользователей)
Сообщение Ответ: Великая битва 4х языков программирования на простейшей задачке

import std.c.windows.windows : GetTickCount;
import std.stdio : writefln, readln;

void main()
{
    int counter = 0;
    auto current = GetTickCount();

    scope map = new int[512 * 128 * 512];

    int allocationTime = GetTickCount() - current;

    writefln("Allocation took: %dms", allocationTime);

    current = GetTickCount();
    for(int i = 0; i < 20; ++i)
    {
        for(int x = 0; x < 512; ++x)
        {
            for(int y = 0; y < 128; ++y)
            {
                for(int z = 0; z < 512;++z)
                {
                    ++counter;
                    map[512 * 128 * x + 128 * y + z] = counter;
                }
            }
        }
    }

    int fillingTime = GetTickCount() - current;

    writefln("Total filling time: %dms", fillingTime);
    writefln("Average fill time per step: %dms", fillingTime/20);

    readln();
}
Версия для D 2.056.
Результаты чуток получше, но, увы...

Allocation took: 125ms
Total filling time: 1609ms
Average fill time per step: 80ms
Ди, к сожалению, далеко не конкурент С++
Вложения
Тип файла: zip test.zip (157.6 Кб, 377 просмотров)
(Offline)
 
Ответить с цитированием