mtrebi / memory-allocators

Custom memory allocators in C++ to improve the performance of dynamic memory allocation
MIT License
1.75k stars 160 forks source link

Fixed build error in MSVC, updated to std library chrono library, etc.. #10

Closed jflopezfernandez closed 4 years ago

jflopezfernandez commented 6 years ago

This error was due to a combination of things, primarily that the Win32 API does not have a few of the time structs defined in <sys/types.h> and <time.h>, as well as <unistd.h>.

To fix the problem, I changed the time tracking mechanism to the standard library's chrono::high_resolution_clock, and updated all the necessary data structures and functions. I also re-added some of the metrics that were commented out. The time elapsed, operations per second, and time per operation metrics are working as expected now.

Excerpt from execution:


    BENCHMARK: ALLOCATION
A   @H 00000292BD9D2070 D@ 00000292BD9D2080 S 4112  AP 0    P 16    M 4112  R 99995888
A   @H 00000292BD9D3080 D@ 00000292BD9D3090 S 80    AP 0    P 16    M 4192  R 99995808
A   @H 00000292BD9D30D0 D@ 00000292BD9D30E0 S 4112  AP 0    P 16    M 8304  R 99991696
A   @H 00000292BD9D40E0 D@ 00000292BD9D40F0 S 2064  AP 0    P 16    M 10368 R 99989632
A   @H 00000292BD9D48F0 D@ 00000292BD9D4900 S 528   AP 0    P 16    M 10896 R 99989104
A   @H 00000292BD9D4B00 D@ 00000292BD9D4B10 S 272   AP 0    P 16    M 11168 R 99988832
A   @H 00000292BD9D4C10 D@ 00000292BD9D4C20 S 2064  AP 0    P 16    M 13232 R 99986768
A   @H 00000292BD9D5420 D@ 00000292BD9D5430 S 48    AP 0    P 16    M 13280 R 99986720
A   @H 00000292BD9D5450 D@ 00000292BD9D5460 S 2064  AP 0    P 16    M 15344 R 99984656
A   @H 00000292BD9D5C60 D@ 00000292BD9D5C70 S 4112  AP 0    P 16    M 19456 R 99980544
    RESULTS:
        Operations:     10
        Time elapsed:   42 ms
        Op per sec:     0.238095 ops/ms
        Timer per op:   4.2 ms/ops
        Memory peak:    19456 bytes

    BENCHMARK: ALLOCATION/FREE
A   @H 00000292BD9D0070 D@ 00000292BD9D0080 S 4112  AP 0    P 16    M 4112  R 99995888
A   @H 00000292BD9D1080 D@ 00000292BD9D1090 S 80    AP 0    P 16    M 4192  R 99995808
A   @H 00000292BD9D10D0 D@ 00000292BD9D10E0 S 4112  AP 0    P 16    M 8304  R 99991696
A   @H 00000292BD9D20E0 D@ 00000292BD9D20F0 S 2064  AP 0    P 16    M 10368 R 99989632
A   @H 00000292BD9D28F0 D@ 00000292BD9D2900 S 528   AP 0    P 16    M 10896 R 99989104
A   @H 00000292BD9D2B00 D@ 00000292BD9D2B10 S 272   AP 0    P 16    M 11168 R 99988832
A   @H 00000292BD9D2C10 D@ 00000292BD9D2C20 S 2064  AP 0    P 16    M 13232 R 99986768
A   @H 00000292BD9D3420 D@ 00000292BD9D3430 S 48    AP 0    P 16    M 13280 R 99986720
A   @H 00000292BD9D3450 D@ 00000292BD9D3460 S 2064  AP 0    P 16    M 15344 R 99984656
A   @H 00000292BD9D3C60 D@ 00000292BD9D3C70 S 4112  AP 0    P 16    M 19456 R 99980544
    Merging(n) 00000292BD9D3C60 & 0000000000000000  S 99984656
F   @ptr 00000292BD9D3C70   H@ 00000292BD9D3C60 S 99984656  M 15344
    Merging(n) 00000292BD9D3450 & 0000000000000000  S 99986720
F   @ptr 00000292BD9D3460   H@ 00000292BD9D3450 S 99986720  M 13280
    Merging(n) 00000292BD9D3420 & 0000000000000000  S 99986768
F   @ptr 00000292BD9D3430   H@ 00000292BD9D3420 S 99986768  M 13232
    Merging(n) 00000292BD9D2C10 & 0000000000000000  S 99988832
F   @ptr 00000292BD9D2C20   H@ 00000292BD9D2C10 S 99988832  M 11168
    Merging(n) 00000292BD9D2B00 & 0000000000000000  S 99989104
F   @ptr 00000292BD9D2B10   H@ 00000292BD9D2B00 S 99989104  M 10896
    Merging(n) 00000292BD9D28F0 & 0000000000000000  S 99989632
F   @ptr 00000292BD9D2900   H@ 00000292BD9D28F0 S 99989632  M 10368
    Merging(n) 00000292BD9D20E0 & 0000000000000000  S 99991696
F   @ptr 00000292BD9D20F0   H@ 00000292BD9D20E0 S 99991696  M 8304
    Merging(n) 00000292BD9D10D0 & 0000000000000000  S 99995808
F   @ptr 00000292BD9D10E0   H@ 00000292BD9D10D0 S 99995808  M 4192
    Merging(n) 00000292BD9D1080 & 0000000000000000  S 99995888
F   @ptr 00000292BD9D1090   H@ 00000292BD9D1080 S 99995888  M 4112
    Merging(n) 00000292BD9D0070 & 0000000000000000  S 100000000
F   @ptr 00000292BD9D0080   H@ 00000292BD9D0070 S 100000000 M 0
    RESULTS:
        Operations:     10
        Time elapsed:   43 ms
        Op per sec:     0.232558 ops/ms
        Timer per op:   4.3 ms/ops
        Memory peak:    19456 bytes
mtrebi commented 4 years ago

Thanks for the fix. Much appreciated! I've been extremely busy with work so I haven't worked on my projects for some time. Sorry this took so long.