Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -1,8 +1,8 @@ TCL_CONFIG_SH := /usr/lib64/tclConfig.sh CPPFLAGS := -I. -DUSE_TCL_STUBS=1 -DXVFS_DEBUG $(shell . "${TCL_CONFIG_SH}" && echo "$${TCL_INCLUDE_SPEC}") $(XVFS_ADD_CPPFLAGS) -CFLAGS := -fPIC -g3 -ggdb3 -Wall $(XVFS_ADD_CFLAGS) +CFLAGS := -fPIC -g3 -ggdb3 -Wall -Wextra $(XVFS_ADD_CFLAGS) LDFLAGS := $(XVFS_ADD_LDFLAGS) LIBS := $(shell . "${TCL_CONFIG_SH}" && echo "$${TCL_STUB_LIB_SPEC}") TCLSH := tclsh LIB_SUFFIX := $(shell . "${TCL_CONFIG_SH}"; echo "$${TCL_SHLIB_SUFFIX:-.so}") @@ -41,10 +41,13 @@ xvfs-create-standalone: $(shell find lib -type f) xvfs-create xvfs-core.c xvfs-core.h xvfs.c.rvt Makefile rm -f xvfs-create-standalone.new xvfs-create-standalone ./xvfs-create --dump-tcl --remove-debug > xvfs-create-standalone.new chmod +x xvfs-create-standalone.new mv xvfs-create-standalone.new xvfs-create-standalone + +benchmark: xvfs$(LIB_SUFFIX) example-flexible$(LIB_SUFFIX) Makefile + ./benchmark.tcl test: example-standalone$(LIB_SUFFIX) xvfs$(LIB_SUFFIX) example-client$(LIB_SUFFIX) example-flexible$(LIB_SUFFIX) Makefile rm -f __test__.tcl echo 'if {[catch { eval $$::env(XVFS_TEST_LOAD_COMMANDS); source //xvfs:/example/main.tcl }]} { puts stderr $$::errorInfo; exit 1 }; exit 0' > __test__.tcl @export XVFS_TEST_LOAD_COMMANDS; for XVFS_TEST_LOAD_COMMANDS in \ @@ -83,6 +86,6 @@ rm -f xvfs-test-coverage.info rm -rf xvfs-test-coverage distclean: clean -.PHONY: all clean distclean test coverage +.PHONY: all clean distclean test coverage benchmark ADDED benchmark.tcl Index: benchmark.tcl ================================================================== --- /dev/null +++ benchmark.tcl @@ -0,0 +1,39 @@ +#! /usr/bin/env tclsh + +set LIB_SUFFIX [info sharedlibextension] +load -global ./xvfs${LIB_SUFFIX}; # Optional, uses a dispatcher +load ./example-flexible${LIB_SUFFIX} Xvfs_example + +set benchmarkFormat "%-6s %-5s: %s" + +proc benchmark {type name code} { + time $code 100 + set time [time $code 10000] + + puts [format $::benchmarkFormat $type $name $time] +} + +set rootDirMap(xvfs) "//xvfs:/example" +set rootDirMap(native) [file join [pwd] example] + +set test(CD) { + cd $::rootDir + pwd +} + +set test(Read) { + set fd [open ${::rootDir}/main.tcl] + read $fd + close $fd +} + +set test(Glob) { + glob -directory ${::rootDir} * +} + +foreach {testName testBody} [lsort -stride 2 -dictionary [array get test]] { + foreach rootDirType {xvfs native} { + set rootDir $rootDirMap($rootDirType) + benchmark $rootDirType $testName $testBody + } +}