Web lists-archives.com

calloc speed difference




Why is the cygwin gcc calloc so much slower than the
i686-w64-mingw32-gcc calloc?
  1:12 vs 0:11

$cat calloc-test.c
#include <stdio.h>
#include <stdlib.h>
#define ALLOCATION_SIZE (100 * 1024 * 1024)
int main (int argc, char *argv[]) {
    for (int i = 0; i < 10000; i++) {
        void *temp = calloc(ALLOCATION_SIZE, 1);
        if ( temp == NULL ) {
           printf("drat! calloc returned NULL\n");
           return 1;
        }
        free(temp);
    }
    return 0;
}

$gcc calloc-test.c
$time ./a

real    1m12.459s
user    0m0.640s
sys     1m11.750s
$i686-w64-mingw32-gcc calloc-test.c
$time ./a

real    0m11.119s
user    0m0.000s
sys     0m0.000s
$gcc calloc-test.c
$time ./a

real    1m12.323s
user    0m0.656s
sys     1m11.640s
$i686-w64-mingw32-gcc calloc-test.c
$time ./a

real    0m11.080s
user    0m0.000s
sys     0m0.000s
$


$ gcc --version
gcc (GCC) 6.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ i686-w64-mingw32-gcc --version
i686-w64-mingw32-gcc (GCC) 6.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple