-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup some core tests. NFC. (#23331)
- Loading branch information
Showing
10 changed files
with
73 additions
and
95 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <emscripten/emmalloc.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
int main() { | ||
void *ptr = malloc(20); | ||
void *ptr2 = malloc(30); | ||
memset(ptr2, 0xFF, 30); | ||
free(ptr2); | ||
printf("%d %d\n", ptr != 0, emmalloc_validate_memory_regions()); | ||
ptr2 = memalign(32, 20); | ||
printf("%d %d\n", ptr2 != 0, emmalloc_validate_memory_regions()); | ||
free(ptr2); | ||
printf("%d\n", emmalloc_validate_memory_regions()); | ||
free(ptr); | ||
printf("%d\n", emmalloc_validate_memory_regions()); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <emscripten/emmalloc.h> | ||
#include <emscripten/heap.h> | ||
|
||
size_t round_to_4k(size_t val){ | ||
return (val + 4095) & ~4095; | ||
} | ||
|
||
void print_stats(int cnt) { | ||
printf("dynamic heap %d: %zu\n", cnt, round_to_4k(emmalloc_dynamic_heap_size())); | ||
printf("free dynamic memory %d: %zu\n", cnt, round_to_4k(emmalloc_free_dynamic_memory())); | ||
printf("unclaimed heap memory %d: %zu\n", cnt, round_to_4k(emmalloc_unclaimed_heap_memory())); | ||
printf("sbrk %d: %#zx\n", cnt, round_to_4k((size_t)sbrk(0))); | ||
} | ||
|
||
int main() { | ||
printf("heap size: %zu\n", emscripten_get_heap_size()); | ||
print_stats(0); | ||
|
||
void *ptr = malloc(32*1024*1024); | ||
void *ptr2 = malloc(4*1024*1024); | ||
printf("%d\n", (int)(ptr && ptr2)); | ||
print_stats(1); | ||
|
||
int success = emmalloc_trim(0); | ||
printf("1st trim: %d\n", success); | ||
print_stats(1); | ||
|
||
success = emmalloc_trim(0); | ||
printf("2nd trim: %d\n", success); | ||
print_stats(2); | ||
free(ptr2); | ||
|
||
success = emmalloc_trim(100000); | ||
printf("3rd trim: %d\n", success); | ||
print_stats(3); | ||
|
||
success = emmalloc_trim(100000); | ||
printf("4th trim: %d\n", success); | ||
print_stats(4); | ||
|
||
success = emmalloc_trim(0); | ||
printf("5th trim: %d\n", success); | ||
print_stats(5); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters