Add bench_libstl, bench_assimp
This commit is contained in:
parent
342c382393
commit
93ddaed71c
15
tests/bench_assimp/bench_assimp.pro
Normal file
15
tests/bench_assimp/bench_assimp.pro
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
include(../../qmake.build/config.pri)
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
TARGET = bench_assimp$$TARGET_SUFFIX
|
||||||
|
|
||||||
|
INCLUDEPATH += $$ASSIMP_ROOT/include
|
||||||
|
|
||||||
|
HEADERS += ../commons/bench_tools.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
../commons/bench_tools.c \
|
||||||
|
main.cpp
|
||||||
|
|
||||||
|
LIBS *= -L$$ASSIMP_ROOT/lib -lassimp
|
||||||
|
QMAKE_RPATHDIR *= $$ASSIMP_ROOT/lib
|
27
tests/bench_assimp/main.cpp
Normal file
27
tests/bench_assimp/main.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include <assimp/IOSystem.hpp>
|
||||||
|
#include <assimp/Exporter.hpp>
|
||||||
|
#include <assimp/Importer.hpp>
|
||||||
|
#include <assimp/ProgressHandler.hpp>
|
||||||
|
#include <assimp/scene.h>
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include "../commons/bench_tools.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
static void assimp_Importer(const char* filepath)
|
||||||
|
{
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene* scene = importer.ReadFile(filepath, 0);
|
||||||
|
if (scene == NULL || scene->mNumMeshes <= 0) {
|
||||||
|
std::cerr << "Failed to read file " << filepath << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
if (argc > 1)
|
||||||
|
benchmark(&assimp_Importer, "Assimp::Importer::ReadFile()", argc - 1, argv + 1);
|
||||||
|
return 0;
|
||||||
|
}
|
17
tests/bench_libstl/bench_libstl.pro
Normal file
17
tests/bench_libstl/bench_libstl.pro
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
include(../../qmake.build/config.pri)
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
TARGET = bench_libstl$$TARGET_SUFFIX
|
||||||
|
|
||||||
|
INCLUDEPATH += $$FOUG_DATAEX_ROOT/include
|
||||||
|
|
||||||
|
HEADERS += ../commons/bench_tools.h
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
../commons/bench_tools.c \
|
||||||
|
main.c
|
||||||
|
|
||||||
|
DEFINES += FOUG_USE_STDINT_H
|
||||||
|
|
||||||
|
LIBS *= -L$$FOUG_DATAEX_ROOT/lib -lfougstl-c$$TARGET_SUFFIX
|
||||||
|
QMAKE_RPATHDIR *= $$FOUG_DATAEX_ROOT/lib
|
63
tests/bench_libstl/main.c
Normal file
63
tests/bench_libstl/main.c
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
#include <dataex/c/libstl/stlb_read.h>
|
||||||
|
|
||||||
|
#include "../commons/bench_tools.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
my_igeom_t* my_igeom = (my_igeom_t*)foug_stlb_geom_input_get_cookie(igeom);
|
||||||
|
if (my_igeom != NULL)
|
||||||
|
++(my_igeom->facet_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void libstl_foug_stlb_read(const char* filepath)
|
||||||
|
{
|
||||||
|
FILE* file = fopen(filepath, "r");
|
||||||
|
if (file == NULL) {
|
||||||
|
fprintf(stderr, "Failed to open STL file %s\n", filepath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foug_stlb_geom_input_manip_t igeom_manip;
|
||||||
|
memset(&igeom_manip, 0, sizeof(foug_stlb_geom_input_manip_t));
|
||||||
|
/* igeom_manip.process_header_func = igeom_process_header; */
|
||||||
|
/* igeom_manip.begin_triangles_func = igeom_begin_triangles; */
|
||||||
|
igeom_manip.process_next_triangle_func = dummy_process_next_triangle;
|
||||||
|
/* igeom_manip.end_triangles_func = NULL; */
|
||||||
|
|
||||||
|
my_igeom_t igeom;
|
||||||
|
igeom.facet_count = 0;
|
||||||
|
|
||||||
|
foug_stlb_read_args_t args;
|
||||||
|
args.geom_input = foug_stlb_geom_input_create(malloc, &igeom, igeom_manip);
|
||||||
|
args.stream = foug_stream_create(&malloc, file, foug_stream_manip_stdio());;
|
||||||
|
args.task_control = NULL;
|
||||||
|
|
||||||
|
args.buffer = (uint8_t*)malloc(512 * 1024);
|
||||||
|
args.buffer_size = 512 * 1024;
|
||||||
|
|
||||||
|
int result = foug_stlb_read(args);
|
||||||
|
if (result != FOUG_STLB_READ_NO_ERROR)
|
||||||
|
fprintf(stderr, "foug_stlb_read() error %i", result);
|
||||||
|
|
||||||
|
fprintf(stdout, "Facet count: %i\n", igeom.facet_count);
|
||||||
|
|
||||||
|
free(args.geom_input);
|
||||||
|
free(args.stream);
|
||||||
|
free(args.buffer);
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
if (argc > 1)
|
||||||
|
benchmark(&libstl_foug_stlb_read, "foug_stlb_read()", argc - 1, argv + 1);
|
||||||
|
return 0;
|
||||||
|
}
|
7
tests/tests.pro
Normal file
7
tests/tests.pro
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
|
SUBDIRS += \
|
||||||
|
bench_occ \
|
||||||
|
bench_libstl \
|
||||||
|
bench_assimp \
|
||||||
|
c-lib
|
Loading…
Reference in New Issue
Block a user