Update tests
This commit is contained in:
parent
ad3eed423f
commit
dc6ca103ee
@ -1,4 +1,6 @@
|
||||
include(../../qmake.build/config.pri)
|
||||
include(../../qmake/config.pri)
|
||||
|
||||
*-g++*:QMAKE_CFLAGS += -ansi -pedantic-errors
|
||||
|
||||
TEMPLATE = app
|
||||
TARGET = bench_libstl$$TARGET_SUFFIX
|
||||
@ -13,5 +15,5 @@ SOURCES += \
|
||||
|
||||
DEFINES += FOUG_USE_STDINT_H
|
||||
|
||||
LIBS *= -L$$FOUG_DATAX_ROOT/lib -lfougdatax-c$$TARGET_SUFFIX
|
||||
QMAKE_RPATHDIR *= $$FOUG_DATAX_ROOT/lib
|
||||
LIBS += -L$$FOUG_DATAX_ROOT/lib -lfougdatax$$TARGET_SUFFIX
|
||||
QMAKE_RPATHDIR += $$FOUG_DATAX_ROOT/lib
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <datax/c/libstl/stla_read.h>
|
||||
#include <datax/c/libstl/stlb_read.h>
|
||||
#include <datax/c/error.h>
|
||||
#include <datax/libstl/stla_read.h>
|
||||
#include <datax/libstl/stlb_read.h>
|
||||
#include <datax/error.h>
|
||||
|
||||
#include "../commons/bench_tools.h"
|
||||
#include <stdio.h>
|
||||
@ -11,36 +11,39 @@ typedef struct my_igeom
|
||||
uint32_t facet_count;
|
||||
} my_igeom_t;
|
||||
|
||||
static void dummy_process_next_triangle(foug_stlb_geom_input_t* igeom,
|
||||
const foug_stlb_triangle_t* triangle)
|
||||
static void dummy_process_triangle(void* cookie,
|
||||
uint32_t triangle_id,
|
||||
const foug_stl_triangle_t* triangle)
|
||||
{
|
||||
my_igeom_t* my_igeom = (my_igeom_t*)(igeom->cookie);
|
||||
my_igeom_t* my_igeom = (my_igeom_t*)(cookie);
|
||||
if (my_igeom != NULL)
|
||||
++(my_igeom->facet_count);
|
||||
}
|
||||
|
||||
static void libstl_foug_stlb_read(const char* filepath)
|
||||
{
|
||||
my_igeom_t cookie;
|
||||
foug_transfer_t trsf;
|
||||
foug_stlb_geom_input_t geom;
|
||||
int result;
|
||||
|
||||
FILE* file = fopen(filepath, "rb");
|
||||
if (file == NULL) {
|
||||
fprintf(stderr, "Failed to open binary STL file %s\n", filepath);
|
||||
return;
|
||||
}
|
||||
|
||||
my_igeom_t cookie;
|
||||
cookie.facet_count = 0;
|
||||
foug_stlb_geom_input_t geom;
|
||||
memset(&geom, 0, sizeof(foug_stlb_geom_input_t));
|
||||
geom.cookie = &cookie;
|
||||
geom.process_next_triangle_func = dummy_process_next_triangle;
|
||||
geom.process_triangle_func = (foug_stlb_process_triangle_func_t)dummy_process_triangle;
|
||||
|
||||
foug_transfer_t trsf;
|
||||
memset(&trsf, 0, sizeof(foug_transfer_t));
|
||||
foug_stream_set_stdio(&trsf.stream, file);
|
||||
trsf.buffer = (uint8_t*)malloc(512 * 1024);
|
||||
trsf.buffer_size = 512 * 1024;
|
||||
|
||||
const int result = foug_stlb_read(&geom, &trsf, FOUG_LITTLE_ENDIAN);
|
||||
result = foug_stlb_read(&geom, &trsf, FOUG_LITTLE_ENDIAN);
|
||||
if (foug_datax_error(result))
|
||||
fprintf(stderr, "foug_stlb_read() error %i", result);
|
||||
|
||||
@ -52,19 +55,22 @@ static void libstl_foug_stlb_read(const char* filepath)
|
||||
|
||||
static void libstl_foug_stla_read(const char* filepath)
|
||||
{
|
||||
FILE* file = fopen(filepath, "r");
|
||||
foug_transfer_t trsf;
|
||||
int result;
|
||||
FILE* file;
|
||||
|
||||
file = fopen(filepath, "r");
|
||||
if (file == NULL) {
|
||||
fprintf(stderr, "Failed to open ascii STL file %s\n", filepath);
|
||||
return;
|
||||
}
|
||||
|
||||
foug_transfer_t trsf;
|
||||
memset(&trsf, 0, sizeof(foug_transfer_t));
|
||||
foug_stream_set_stdio(&trsf.stream, file);
|
||||
trsf.buffer = (char*)malloc(512 * 1024);
|
||||
trsf.buffer_size = 512 * 1024;
|
||||
|
||||
const int result = foug_stla_read(NULL, &trsf, 0);
|
||||
result = foug_stla_read(NULL, &trsf, 0);
|
||||
if (foug_datax_error(result))
|
||||
fprintf(stderr, "foug_stla_read() error %i", result);
|
||||
|
||||
|
@ -9,16 +9,16 @@ float elapsed_secs(clock_t start_tick)
|
||||
|
||||
void benchmark(void (*func)(const char*), const char* title, int argc, char** argv)
|
||||
{
|
||||
const clock_t start_tick = clock();
|
||||
int iarg;
|
||||
|
||||
if (func == NULL)
|
||||
return;
|
||||
|
||||
const clock_t start_tick = clock();
|
||||
|
||||
fprintf(stdout, "Bench %s ...\n", title);
|
||||
int iarg;
|
||||
printf("Bench %s ...\n", title);
|
||||
for (iarg = 0; iarg < argc; ++iarg) {
|
||||
fprintf(stdout, " Read file %s ...\n", argv[iarg]);
|
||||
printf(" Read file %s ...\n", argv[iarg]);
|
||||
(*func)(argv[iarg]);
|
||||
}
|
||||
fprintf(stdout, "\n %s exec time: %.2fs\n", title, elapsed_secs(start_tick));
|
||||
printf("\n %s exec time: %.2fs\n", title, elapsed_secs(start_tick));
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
TEMPLATE = subdirs
|
||||
|
||||
SUBDIRS += \
|
||||
bench_occ \
|
||||
#bench_occ \
|
||||
bench_libstl \
|
||||
bench_assimp \
|
||||
c-lib
|
||||
#bench_assimp \
|
||||
#c-lib
|
||||
|
Loading…
Reference in New Issue
Block a user