loader_aw

Load OBJ/MTL file formats
git clone git://git.meso-star.fr/loader_aw.git
Log | Files | Refs | README | LICENSE

commit 8f7c28727c56d4292832e2c5e25c7f3fd12dafea
parent c88cd775a73036f0ab727a0847260d2a17e5fa6e
Author: vaplv <vaplv@free.fr>
Date:   Sun,  7 Dec 2014 14:43:34 +0100

Dump the <obj|mtl> loading time

Diffstat:
Msrc/aw_mtl.c | 13+++++++++++++
Msrc/aw_obj.c | 24+++++++++++++++++-------
2 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/src/aw_mtl.c b/src/aw_mtl.c @@ -17,6 +17,7 @@ #include "aw_c.h" +#include <rsys/clock_time.h> #include <rsys/dynamic_array_char.h> #include <rsys/float3.h> #include <rsys/logger.h> @@ -617,7 +618,9 @@ aw_mtl_load(struct aw_mtl* mtl, const char* filename) res_T aw_mtl_load_stream(struct aw_mtl* mtl, FILE* stream) { + char dump[64]; char* line; + struct time t0, t1; struct darray_char buf; const unsigned buf_chunk = 256; res_T res = RES_OK; @@ -636,6 +639,10 @@ aw_mtl_load_stream(struct aw_mtl* mtl, FILE* stream) mtl->filename = "stream"; mtl->iline = 1; mtl_clear(mtl); + + logger_print(mtl->logger, LOG_OUTPUT, "Loading the mtl %s\n", mtl->filename); + time_current(&t0); + while((line = fgets (darray_char_data_get(&buf), (int)darray_char_size_get(&buf), stream))) { size_t last_char; @@ -658,6 +665,12 @@ aw_mtl_load_stream(struct aw_mtl* mtl, FILE* stream) ++mtl->iline; } + time_current(&t1); + time_sub(&t1, &t1, &t0); + time_dump(&t1, TIME_MIN|TIME_SEC|TIME_MSEC, NULL, dump, sizeof(dump)); + logger_print(mtl->logger, LOG_OUTPUT, + "%s loaded in %s\n", mtl->filename, dump); + exit: if(mtl && stream) darray_char_release(&buf); diff --git a/src/aw_obj.c b/src/aw_obj.c @@ -17,6 +17,7 @@ #include "aw_c.h" +#include <rsys/clock_time.h> #include <rsys/dynamic_array_char.h> #include <rsys/dynamic_array_float.h> #include <rsys/float3.h> @@ -121,8 +122,8 @@ struct aw_obj { size_t igroups_active; /* Index toward the first active group */ - const char* filename; /* Currently parsed file. Use in error messages */ - size_t iline; /* Currently parsed line index. Use in error messages */ + const char* filename; /* Currently parsed file. Use in messages */ + size_t iline; /* Currently parsed line index. Use in messages */ ref_T ref; struct mem_allocator* allocator; @@ -565,8 +566,7 @@ error: res_T aw_obj_ref_get(struct aw_obj* obj) { - if(!obj) - return RES_BAD_ARG; + if(!obj) return RES_BAD_ARG; ref_get(&obj->ref); return RES_OK; } @@ -574,8 +574,7 @@ aw_obj_ref_get(struct aw_obj* obj) res_T aw_obj_ref_put(struct aw_obj* obj) { - if(!obj) - return RES_BAD_ARG; + if(!obj) return RES_BAD_ARG; ref_put(&obj->ref, obj_release); return RES_OK; } @@ -595,7 +594,6 @@ aw_obj_load(struct aw_obj* obj, const char* filename) logger_print(obj->logger, LOG_ERROR, "Error opening `%s'\n", filename); return RES_IO_ERR; } - res = aw_obj_load_stream(obj, file); obj->filename = NULL; fclose(file); @@ -605,8 +603,10 @@ aw_obj_load(struct aw_obj* obj, const char* filename) res_T aw_obj_load_stream(struct aw_obj* obj, FILE* stream) { + char dump[64]; char* line; struct darray_char buf; + struct time t0, t1; const unsigned buf_chunk = 256; res_T res = RES_OK; @@ -624,6 +624,10 @@ aw_obj_load_stream(struct aw_obj* obj, FILE* stream) obj->filename = "stream"; obj->iline = 1; obj_clear(obj); + + logger_print(obj->logger, LOG_OUTPUT, "Loading the obj %s\n", obj->filename); + time_current(&t0); + while((line = fgets (darray_char_data_get(&buf), (int)darray_char_size_get(&buf), stream))) { size_t last_char; @@ -651,6 +655,12 @@ aw_obj_load_stream(struct aw_obj* obj, FILE* stream) flush_smooth_group(obj); flush_usemtl(obj); + time_current(&t1); + time_sub(&t1, &t1, &t0); + time_dump(&t1, TIME_MIN|TIME_SEC|TIME_MSEC, NULL, dump, sizeof(dump)); + logger_print(obj->logger, LOG_OUTPUT, + "%s loaded in %s\n", obj->filename, dump); + exit: if(obj && stream) darray_char_release(&buf);