Index: .fossil-settings/ignore-glob ================================================================== --- .fossil-settings/ignore-glob +++ .fossil-settings/ignore-glob @@ -21,7 +21,10 @@ xvfs-test-coverage __test__.tcl sdks xvfs_random.so xvfs_synthetic.so -profile +profile-bare +profile-gperf oprofile_data +gmon.out +callgrind.out Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -79,19 +79,25 @@ 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 +profile-bare: profile.c example.c xvfs-core.h xvfs-core.c Makefile + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -UUSE_TCL_STUBS -o profile-bare profile.c -ltcl + +profile-gperf: profile.c example.c xvfs-core.h xvfs-core.c Makefile + $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -pg -UUSE_TCL_STUBS -o profile-gperf profile.c -ltcl + +do-profile: profile-bare profile-gperf Makefile + rm -rf oprofile_data + rm -f gmon.out callgrind.out + operf ./profile-bare + opreport + ./profile-gperf + gprof ./profile-gperf + valgrind --tool=callgrind --callgrind-out-file=callgrind.out ./profile-bare 10 2 + callgrind_annotate callgrind.out 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 @@ -102,13 +108,15 @@ 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 -f profile-bare profile-gperf + rm -f gmon.out + rm -f callgrind.out rm -rf oprofile_data rm -f xvfs-test-coverage.info rm -rf xvfs-test-coverage distclean: clean .PHONY: all clean distclean test do-test do-coverage do-benchmark do-profile Index: profile.c ================================================================== --- profile.c +++ profile.c @@ -1,14 +1,29 @@ #include #include +#include -extern int Xvfs_Init(Tcl_Interp *interp); -extern int Xvfs_example_Init(Tcl_Interp *interp); +#undef XVFS_DEBUG +#define XVFS_MODE_STANDALONE +#include "example.c" + int main(int argc, char **argv) { Tcl_Interp *interp; + int profileTests, profileBenchmark; int tclRet; int try; + + profileTests = 0; + profileBenchmark = 1000000; + + if (argc > 1) { + profileBenchmark = atoi(argv[1]); + } + + if (argc > 2) { + profileTests = atoi(argv[2]); + } interp = Tcl_CreateInterp(); if (!interp) { fprintf(stderr, "Tcl_CreateInterp failed\n"); @@ -20,35 +35,26 @@ 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 * }"); + for (try = 0; try < profileBenchmark; try++) { + Tcl_Eval(interp, "benchmark"); + } -#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++) { + for (try = 0; try < profileTests; try++) { Tcl_EvalFile(interp, "//xvfs:/example/main.tcl"); } -#else - for (try = 0; try < 1000000; try++) { - Tcl_Eval(interp, "benchmark"); - } -#endif return(0); }