Итак, я пытался использовать std:: chrono:: high_resolution_clock во времени, сколько времени требуется для выполнения. Я решил, что вы можете просто найти разницу между временем начала и временем окончания...
Чтобы проверить работу моего подхода, я сделал следующую программу:
#include <iostream>
#include <chrono>
#include <vector>
void long_function();
int main()
{
    std::chrono::high_resolution_clock timer;
    auto start_time = timer.now();
    long_function();
    auto end_time = timer.now();
    auto diff_millis = std::chrono::duration_cast<std::chrono::duration<int, std::milli>>(end_time - start_time);
    std::cout << "It took " << diff_millis.count() << "ms" << std::endl;
    return 0;
}
void long_function()
{
    //Should take a while to execute.
    //This is calculating the first 100 million
    //fib numbers and storing them in a vector.
    //Well, it doesn't actually, because it
    //overflows very quickly, but the point is it
    //should take a few seconds to execute.
    std::vector<unsigned long> numbers;
    numbers.push_back(1);
    numbers.push_back(1);
    for(int i = 2; i < 100000000; i++)
    {
        numbers.push_back(numbers[i-2] + numbers[i-1]);
    }
}
Проблема в том, что она просто выводит 3000 мс точно, когда это явно не было на самом деле.
В более коротких проблемах он просто выводит 0 мс... Что я делаю неправильно?
EDIT: если он используется, я использую компилятор GNU GCC с флагом -std = С++ 0x на
