Index: .fossil-settings/ignore-glob ================================================================== --- .fossil-settings/ignore-glob +++ .fossil-settings/ignore-glob @@ -21,5 +21,7 @@ xvfs-test-coverage __test__.tcl sdks xvfs_random.so xvfs_synthetic.so +profile +oprofile_data Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -49,11 +49,11 @@ ./xvfs-create-random | $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DXVFS_MODE_FLEXIBLE -x c - -shared -o xvfs_random$(LIB_SUFFIX) $(LIBS) xvfs_synthetic$(LIB_SUFFIX): $(shell find lib -type f) lib/xvfs/xvfs.c.rvt xvfs-create-synthetic Makefile ./xvfs-create-synthetic | $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DXVFS_MODE_FLEXIBLE -x c - -shared -o xvfs_synthetic$(LIB_SUFFIX) $(LIBS) -benchmark: +do-benchmark: $(MAKE) clean all XVFS_ADD_CPPFLAGS="-UXVFS_DEBUG" XVFS_ADD_CFLAGS="-g0 -ggdb0 -s -O3" ./benchmark.tcl test: example-standalone$(LIB_SUFFIX) xvfs$(LIB_SUFFIX) example-client$(LIB_SUFFIX) example-flexible$(LIB_SUFFIX) Makefile rm -f __test__.tcl @@ -66,20 +66,32 @@ echo "[$${XVFS_TEST_LOAD_COMMANDS}] $(GDB) $(TCLSH) __test__.tcl $(TCL_TEST_ARGS)"; \ $(GDB) $(TCLSH) __test__.tcl $(TCL_TEST_ARGS) || exit 1; \ done rm -f __test__.tcl -coverage: +do-test: test + +do-coverage: $(MAKE) clean $(MAKE) XVFS_ADD_CFLAGS=-coverage XVFS_ADD_LDFLAGS=-coverage $(MAKE) test XVFS_TEST_EXIT_ON_FAILURE=0 rm -f xvfs-test-coverage.info lcov --capture --directory . --output-file xvfs-test-coverage.info rm -rf xvfs-test-coverage mkdir xvfs-test-coverage genhtml xvfs-test-coverage.info --output-directory xvfs-test-coverage rm -f xvfs-test-coverage.info + +profile: profile.c Makefile + rm -f example-client$(LIB_SUFFIX) xvfs$(LIB_SUFFIX) + $(MAKE) xvfs$(LIB_SUFFIX) example-client$(LIB_SUFFIX) XVFS_ADD_CPPFLAGS="-UXVFS_DEBUG" + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -UUSE_TCL_STUBS ./xvfs$(LIB_SUFFIX) ./example-client$(LIB_SUFFIX) -o profile profile.c -ltcl + +do-profile: profile Makefile + rm -rf oprofile_data + LD_LIBRARY_PATH='$(shell pwd):$(LD_LIBRARY_PATH)' operf ./profile + opreport clean: rm -f xvfs-create-standalone.new xvfs-create-standalone rm -f example.c example.c.new rm -f example-standalone$(LIB_SUFFIX) example-standalone.o @@ -90,11 +102,13 @@ rm -f example-client.gcda example-client.gcno rm -f example-flexible.gcda example-flexible.gcno rm -f xvfs_random$(LIB_SUFFIX) xvfs_synthetic$(LIB_SUFFIX) rm -f xvfs.gcda xvfs.gcno rm -f __test__.tcl + rm -f profile + rm -rf oprofile_data rm -f xvfs-test-coverage.info rm -rf xvfs-test-coverage distclean: clean -.PHONY: all clean distclean test coverage benchmark +.PHONY: all clean distclean test do-test do-coverage do-benchmark do-profile ADDED profile.c Index: profile.c ================================================================== --- /dev/null +++ profile.c @@ -0,0 +1,54 @@ +#include +#include + +extern int Xvfs_Init(Tcl_Interp *interp); +extern int Xvfs_example_Init(Tcl_Interp *interp); +int main(int argc, char **argv) { + Tcl_Interp *interp; + int tclRet; + int try; + + interp = Tcl_CreateInterp(); + if (!interp) { + fprintf(stderr, "Tcl_CreateInterp failed\n"); + + return(1); + } + + tclRet = Tcl_Init(interp); + if (tclRet != TCL_OK) { + fprintf(stderr, "Tcl_Init failed: %s\n", Tcl_GetStringResult(interp)); + + return(1); + } + + tclRet = Xvfs_Init(interp); + if (tclRet != TCL_OK) { + fprintf(stderr, "Xvfs_Init failed: %s\n", Tcl_GetStringResult(interp)); + + return(1); + } + tclRet = Xvfs_example_Init(interp); + if (tclRet != TCL_OK) { + fprintf(stderr, "Xvfs_example_Init failed: %s\n", Tcl_GetStringResult(interp)); + + return(1); + } + + Tcl_Eval(interp, "proc benchmark args { glob -directory //xvfs:/example * }"); + +#ifdef XVFS_PROFILE_TESTS + Tcl_Eval(interp, "proc exit args {}"); + Tcl_Eval(interp, "proc puts args {}"); + Tcl_SetVar(interp, "argv", "-verbose {}", 0); + for (try = 0; try < 1000; try++) { + Tcl_EvalFile(interp, "//xvfs:/example/main.tcl"); + } +#else + for (try = 0; try < 1000000; try++) { + Tcl_Eval(interp, "benchmark"); + } +#endif + + return(0); +}