C++ code is much slower on linux than on windows : <p>I'm writing simple program and I want to mesure time of its execution on Windows and Linux (both 64). I have a problem, because for 1 000 000 elements in table on Windows it takes about 35 seconds, while on linux it takes about 30 seconds for 10 elements. Why the difference is so huge? 
What am I doing wrong? Is there something in my code that is not proper on Linux? </p>

<p>Here is my code:</p>

<pre><code>void fillTable(int s, int t[])
{
    srand(time(0));
    for (int i = 0; i &lt; s; i++)
    {
        t[i] = rand();
    }
}
void checkIfIsPrimeNotParalleled(int size, int table[])
{
    for (int i = 0; i &lt; size; i++)
    {
        int tmp = table[i];

        if (tmp &lt; 2)
        {
        }


        for (int i = 2; i &lt; tmp; i++)
        {
            if (tmp % i == 0)
            {
            }
            else
            {
            }
        }
    }
}
void mesureTime(int size, int table[], int numberOfRepetitions)
{
    long long sum = 0;
    clock_t start_time, end_time;
    fillTable(size, table);

    for (int i = 0; i &lt; numberOfRepetitions; i++)
    {
        start_time = clock();

        checkIfIsPrimeNotParalleled(size, table); 

        end_time = clock();
        double duration = (end_time - start_time) / CLOCKS_PER_SEC;
        sum += duration;
    }
    cout &lt;&lt; "Avg: " &lt;&lt; round(sum / numberOfRepetitions) &lt;&lt; " s"&lt;&lt;endl;
}

int main()
{

    static constexpr int size = 1000000; 
    int *table = new int[size];
    int numberOfRepetitions = 1;
    mesureTime(size, table, numberOfRepetitions);
    delete[] table;
    return 0;

}
</code></pre>

<p>and the makefile for Linux. On Windows I'm using Visual Studio 2015</p>

<pre><code>.PHONY: Project1

CXX = g++
EXEC = tablut
LDFLAGS = -fopenmp
CXXFLAGS = -std=c++11 -Wall -Wextra -fopenmp -m64
SRC= Project1.cpp
OBJ= $(SRC:.cpp=.o)

all: $(EXEC)

tablut: $(OBJ)
    $(CXX) -o tablut $(OBJ) $(LDFLAGS)

%.o: %.cpp
    $(CXX) -o $@ -c $&lt; $(CXXFLAGS) 

clean:
    rm -rf *.o

mrproper: clean
    rm -rf tablut
</code></pre>

<p>The main goal is to mesure time.</p>
