From 226532f8f39e8d37d392282ed57aa891c0e69736 Mon Sep 17 00:00:00 2001 From: Araq Date: Thu, 7 Dec 2017 15:58:46 +0100 Subject: cleanup todo.txt --- tests/fragmentation/tfragment_alloc.nim | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/fragmentation/tfragment_alloc.nim (limited to 'tests/fragmentation/tfragment_alloc.nim') diff --git a/tests/fragmentation/tfragment_alloc.nim b/tests/fragmentation/tfragment_alloc.nim new file mode 100644 index 000000000..6ee8322c7 --- /dev/null +++ b/tests/fragmentation/tfragment_alloc.nim @@ -0,0 +1,19 @@ + + + +include system/ansi_c + +import strutils, data + +proc main = + var m = 0 + for i in 0..1000_000: + let size = sizes[i mod sizes.len] + let p = alloc(size) + if p == nil: + quit "could not serve request!" + dealloc p + # c_fprintf(stdout, "iteration: %ld size: %ld\n", i, size) + +main() +echo formatSize getOccupiedMem(), " / ", formatSize getTotalMem() -- cgit 1.4.1-2-gfad0 From c96e1d0180daebd67a4e48d7665069d70164789d Mon Sep 17 00:00:00 2001 From: Araq Date: Thu, 7 Dec 2017 17:03:15 +0100 Subject: enable fragmentation tests --- tests/fragmentation/tfragment_alloc.nim | 16 ++++++++++++---- tests/fragmentation/tfragment_gc.nim | 20 ++++++++++++++------ 2 files changed, 26 insertions(+), 10 deletions(-) (limited to 'tests/fragmentation/tfragment_alloc.nim') diff --git a/tests/fragmentation/tfragment_alloc.nim b/tests/fragmentation/tfragment_alloc.nim index 6ee8322c7..031588d27 100644 --- a/tests/fragmentation/tfragment_alloc.nim +++ b/tests/fragmentation/tfragment_alloc.nim @@ -1,7 +1,8 @@ - - -include system/ansi_c +discard """ + output: '''occupied ok: true +total ok: true''' +""" import strutils, data @@ -16,4 +17,11 @@ proc main = # c_fprintf(stdout, "iteration: %ld size: %ld\n", i, size) main() -echo formatSize getOccupiedMem(), " / ", formatSize getTotalMem() + +let occ = getOccupiedMem() +let total = getTotalMem() + +# Current values on Win64: 824KiB / 106.191MiB + +echo "occupied ok: ", occ < 2 * 1024 * 1024 +echo "total ok: ", total < 120 * 1024 * 1024 diff --git a/tests/fragmentation/tfragment_gc.nim b/tests/fragmentation/tfragment_gc.nim index 41f86136c..42f2f1cf6 100644 --- a/tests/fragmentation/tfragment_gc.nim +++ b/tests/fragmentation/tfragment_gc.nim @@ -1,16 +1,24 @@ - - - -#include system/ansi_c +discard """ + output: '''occupied ok: true +total ok: true''' +""" import strutils, data proc main = var m = 0 - for i in 0..1000_000: + # Since the GC test is slower than the alloc test, we only iterate 100_000 times here: + for i in 0..100_000: let size = sizes[i mod sizes.len] let p = newString(size) # c_fprintf(stdout, "iteration: %ld size: %ld\n", i, size) main() -echo formatSize getOccupiedMem(), " / ", formatSize getTotalMem() + +let occ = getOccupiedMem() +let total = getTotalMem() + +# Concrete values on Win64: 58.152MiB / 188.285MiB + +echo "occupied ok: ", occ < 60 * 1024 * 1024 +echo "total ok: ", total < 200 * 1024 * 1024 -- cgit 1.4.1-2-gfad0