From 432f24319319fe040e142059eb83279c53f90ab8 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Sat, 9 Aug 2025 08:35:03 +0200 Subject: refactor 2 --- libs/simclist-1.5/perftest/._README-perftest.txt | Bin 0 -> 229 bytes libs/simclist-1.5/perftest/._ext.c | Bin 0 -> 229 bytes libs/simclist-1.5/perftest/._ins.c | Bin 0 -> 229 bytes libs/simclist-1.5/perftest/._sort.c | Bin 0 -> 229 bytes libs/simclist-1.5/perftest/README-perftest.txt | 34 +++++++++++++++++++++++ libs/simclist-1.5/perftest/ext.c | 31 +++++++++++++++++++++ libs/simclist-1.5/perftest/ins.c | 17 ++++++++++++ libs/simclist-1.5/perftest/sort.c | 24 ++++++++++++++++ 8 files changed, 106 insertions(+) create mode 100644 libs/simclist-1.5/perftest/._README-perftest.txt create mode 100644 libs/simclist-1.5/perftest/._ext.c create mode 100644 libs/simclist-1.5/perftest/._ins.c create mode 100644 libs/simclist-1.5/perftest/._sort.c create mode 100644 libs/simclist-1.5/perftest/README-perftest.txt create mode 100644 libs/simclist-1.5/perftest/ext.c create mode 100644 libs/simclist-1.5/perftest/ins.c create mode 100644 libs/simclist-1.5/perftest/sort.c (limited to 'libs/simclist-1.5/perftest') diff --git a/libs/simclist-1.5/perftest/._README-perftest.txt b/libs/simclist-1.5/perftest/._README-perftest.txt new file mode 100644 index 0000000..fd67f74 Binary files /dev/null and b/libs/simclist-1.5/perftest/._README-perftest.txt differ diff --git a/libs/simclist-1.5/perftest/._ext.c b/libs/simclist-1.5/perftest/._ext.c new file mode 100644 index 0000000..70f73dd Binary files /dev/null and b/libs/simclist-1.5/perftest/._ext.c differ diff --git a/libs/simclist-1.5/perftest/._ins.c b/libs/simclist-1.5/perftest/._ins.c new file mode 100644 index 0000000..17ab7f1 Binary files /dev/null and b/libs/simclist-1.5/perftest/._ins.c differ diff --git a/libs/simclist-1.5/perftest/._sort.c b/libs/simclist-1.5/perftest/._sort.c new file mode 100644 index 0000000..168e05d Binary files /dev/null and b/libs/simclist-1.5/perftest/._sort.c differ diff --git a/libs/simclist-1.5/perftest/README-perftest.txt b/libs/simclist-1.5/perftest/README-perftest.txt new file mode 100644 index 0000000..127e51a --- /dev/null +++ b/libs/simclist-1.5/perftest/README-perftest.txt @@ -0,0 +1,34 @@ +SimCList performance test cases + +===== ins.c +insert 10 000 000 (ten million) elements into a list, with element autocopy +disabled. +Compile: + gcc -O2 -I.. -std=c99 -o ins ins.c ../simclist.c +Use: + time ./ins + + +===== ext.c +insert 1 000 000 (one million) elements with element autocopy, then extracts 1 +000 elements at random position (from a Uniform(0, list_size) probability +density function). +Compile: + gcc -O2 -I.. -std=c99 -o ext ext.c ../simclist.c +Use: + time ./ext + + +===== sort.c +insert 1 000 000 elements with autocopy, then sorting. + +Compile: + # for testing the default setup + gcc -O2 -I.. -std=c99 -o sort sort.c ../simclist.c + # for testing with threading enabled + gcc -DSIMCLIST_WITH_THREADS -O2 -I.. -std=c99 -o sort sort.c ../simclist.c +Use: + # generate data to insert into the list + # e.g. for ((i = 0; i<1000000; i++)); do echo $RANDOM; done >randdata.txt + time ./sort < randdata.txt + diff --git a/libs/simclist-1.5/perftest/ext.c b/libs/simclist-1.5/perftest/ext.c new file mode 100644 index 0000000..8288b84 --- /dev/null +++ b/libs/simclist-1.5/perftest/ext.c @@ -0,0 +1,31 @@ + +#include +#include +#include +#include + +#define NELS 1000000 + +size_t szelem(const void *el) { + return sizeof(int); +} + +int main() { + list_t l; + int i; + + srandom(time(NULL)); + + list_init(&l); + list_attributes_copy(&l, szelem, 1); + + for (i = 0; i < NELS; i++) { + list_append(&l, &i); + } + + for (i = 0; i < 1000; i++) { + list_get_at(&l, random()%NELS); + } + + return 0; +} diff --git a/libs/simclist-1.5/perftest/ins.c b/libs/simclist-1.5/perftest/ins.c new file mode 100644 index 0000000..e7d1c19 --- /dev/null +++ b/libs/simclist-1.5/perftest/ins.c @@ -0,0 +1,17 @@ + +#include +#include + +#define NELS 10000000 + +int main() { + list_t l; + int i; + + list_init(&l); + for (i = 0; i < NELS; i++) { + list_append(&l, &i); + } + + return 0; +} diff --git a/libs/simclist-1.5/perftest/sort.c b/libs/simclist-1.5/perftest/sort.c new file mode 100644 index 0000000..171c8d7 --- /dev/null +++ b/libs/simclist-1.5/perftest/sort.c @@ -0,0 +1,24 @@ +#include +#include +#include + +#define BUFLEN 20 + +int main() { + list_t l; + unsigned int i; + char buf[BUFLEN]; + + list_init(&l); + list_attributes_copy(&l, list_meter_int32_t, 1); + list_attributes_comparator(&l, list_comparator_int32_t); + + while (fgets(buf, BUFLEN, stdin) != NULL) { + i = atoi(buf); + list_append(&l, &i); + } + + list_sort(&l, 1); + + return 0; +} -- cgit v1.2.3-70-g09d2