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
|
TEMPLATE = app
|
||||||
TARGET = bench_libstl$$TARGET_SUFFIX
|
TARGET = bench_libstl$$TARGET_SUFFIX
|
||||||
@ -13,5 +15,5 @@ SOURCES += \
|
|||||||
|
|
||||||
DEFINES += FOUG_USE_STDINT_H
|
DEFINES += FOUG_USE_STDINT_H
|
||||||
|
|
||||||
LIBS *= -L$$FOUG_DATAX_ROOT/lib -lfougdatax-c$$TARGET_SUFFIX
|
LIBS += -L$$FOUG_DATAX_ROOT/lib -lfougdatax$$TARGET_SUFFIX
|
||||||
QMAKE_RPATHDIR *= $$FOUG_DATAX_ROOT/lib
|
QMAKE_RPATHDIR += $$FOUG_DATAX_ROOT/lib
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <datax/c/libstl/stla_read.h>
|
#include <datax/libstl/stla_read.h>
|
||||||
#include <datax/c/libstl/stlb_read.h>
|
#include <datax/libstl/stlb_read.h>
|
||||||
#include <datax/c/error.h>
|
#include <datax/error.h>
|
||||||
|
|
||||||
#include "../commons/bench_tools.h"
|
#include "../commons/bench_tools.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -11,36 +11,39 @@ typedef struct my_igeom
|
|||||||
uint32_t facet_count;
|
uint32_t facet_count;
|
||||||
} my_igeom_t;
|
} my_igeom_t;
|
||||||
|
|
||||||
static void dummy_process_next_triangle(foug_stlb_geom_input_t* igeom,
|
static void dummy_process_triangle(void* cookie,
|
||||||
const foug_stlb_triangle_t* triangle)
|
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)
|
if (my_igeom != NULL)
|
||||||
++(my_igeom->facet_count);
|
++(my_igeom->facet_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void libstl_foug_stlb_read(const char* filepath)
|
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");
|
FILE* file = fopen(filepath, "rb");
|
||||||
if (file == NULL) {
|
if (file == NULL) {
|
||||||
fprintf(stderr, "Failed to open binary STL file %s\n", filepath);
|
fprintf(stderr, "Failed to open binary STL file %s\n", filepath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
my_igeom_t cookie;
|
|
||||||
cookie.facet_count = 0;
|
cookie.facet_count = 0;
|
||||||
foug_stlb_geom_input_t geom;
|
|
||||||
memset(&geom, 0, sizeof(foug_stlb_geom_input_t));
|
memset(&geom, 0, sizeof(foug_stlb_geom_input_t));
|
||||||
geom.cookie = &cookie;
|
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));
|
memset(&trsf, 0, sizeof(foug_transfer_t));
|
||||||
foug_stream_set_stdio(&trsf.stream, file);
|
foug_stream_set_stdio(&trsf.stream, file);
|
||||||
trsf.buffer = (uint8_t*)malloc(512 * 1024);
|
trsf.buffer = (uint8_t*)malloc(512 * 1024);
|
||||||
trsf.buffer_size = 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))
|
if (foug_datax_error(result))
|
||||||
fprintf(stderr, "foug_stlb_read() error %i", 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)
|
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) {
|
if (file == NULL) {
|
||||||
fprintf(stderr, "Failed to open ascii STL file %s\n", filepath);
|
fprintf(stderr, "Failed to open ascii STL file %s\n", filepath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
foug_transfer_t trsf;
|
|
||||||
memset(&trsf, 0, sizeof(foug_transfer_t));
|
memset(&trsf, 0, sizeof(foug_transfer_t));
|
||||||
foug_stream_set_stdio(&trsf.stream, file);
|
foug_stream_set_stdio(&trsf.stream, file);
|
||||||
trsf.buffer = (char*)malloc(512 * 1024);
|
trsf.buffer = (char*)malloc(512 * 1024);
|
||||||
trsf.buffer_size = 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))
|
if (foug_datax_error(result))
|
||||||
fprintf(stderr, "foug_stla_read() error %i", 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)
|
void benchmark(void (*func)(const char*), const char* title, int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
const clock_t start_tick = clock();
|
||||||
|
int iarg;
|
||||||
|
|
||||||
if (func == NULL)
|
if (func == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const clock_t start_tick = clock();
|
printf("Bench %s ...\n", title);
|
||||||
|
|
||||||
fprintf(stdout, "Bench %s ...\n", title);
|
|
||||||
int iarg;
|
|
||||||
for (iarg = 0; iarg < argc; ++iarg) {
|
for (iarg = 0; iarg < argc; ++iarg) {
|
||||||
fprintf(stdout, " Read file %s ...\n", argv[iarg]);
|
printf(" Read file %s ...\n", argv[iarg]);
|
||||||
(*func)(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
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
SUBDIRS += \
|
SUBDIRS += \
|
||||||
bench_occ \
|
#bench_occ \
|
||||||
bench_libstl \
|
bench_libstl \
|
||||||
bench_assimp \
|
#bench_assimp \
|
||||||
c-lib
|
#c-lib
|
||||||
|
Loading…
Reference in New Issue
Block a user