Check-in [200a60c198]
Overview
Comment:More benchmarks
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 200a60c198a3145943c53ec1b5d8c856891083e84b51a6aa25c2edeb9f762502
User & Date: rkeene on 2019-09-18 00:14:24
Other Links: manifest | tags
Context
2019-09-18
04:59
Sped up encoding files check-in: 2176e9cacf user: rkeene tags: trunk
00:14
More benchmarks check-in: 200a60c198 user: rkeene tags: trunk
00:13
Generate readable events even after EOF, since it will not block check-in: bdabc41e51 user: rkeene tags: trunk
Changes

Modified benchmark.tcl from [23868591a9] to [de7844d2bc].

1
2
3
4
5
6
7
8
9







10
11
12
13
14
15
16
17
18






19

20
21
22
23
24
25
26
27
28










29




30
31












32
33
34
35
36
37
38
#! /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
	}






|


>
>
>
>
>
>
>
|
|







>
>
>
>
>
>
|
>
|
|
|
<
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
|
|
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /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  %-11s  %s"

proc benchmark {type name code} {
	set iterations 10000

	set work [string trim [lindex [split [string trim $code] "\n"] 0]]
	if {[string match "# iterations: *" $work]} {
		set iterations [lindex $work 2]
	}
	
	time $code [expr {max($iterations / 100, 1)}]
	set time [time $code $iterations]

	puts [format $::benchmarkFormat $type $name $time]
}

set rootDirMap(xvfs) "//xvfs:/example"
set rootDirMap(native) [file join [pwd] example]

proc recursiveGlob {dir} {
	foreach subDir [glob -nocomplain -directory $dir -types d *] {
		recursiveGlob $subDir
	}
}

array set test {
	CD {
		cd $::rootDir
		pwd
	}

	Read {
		set fd [open ${::rootDir}/main.tcl]
		read $fd
		close $fd
	}
	"Read Async" {
		# iterations: 1000
		set ::async_read_done false
		set fd [open ${::rootDir}/main.tcl]
		fconfigure $fd -blocking false
		fileevent $fd readable [list apply {{fd} {
			set input [read $fd 512]
			if {[eof $fd] && $input eq ""} {
				set ::async_read_done true
				return
			}
		}} $fd]
		vwait ::async_read_done
		close $fd
	}
	Glob {
		glob -directory ${::rootDir} *
	}
	Search {
		recursiveGlob ${::rootDir}
	}
	+Stat {
		file stat ${::rootDir}/main.tcl UNUSED
	}
	-Stat {
		catch {
			file stat ${::rootDir}/DOES-NOT-EXIST UNUSED
		}
	}
}

foreach {testName testBody} [lsort -stride 2 -dictionary [array get test]] {
	foreach rootDirType {xvfs native} {
		set rootDir $rootDirMap($rootDirType)
		benchmark $rootDirType $testName $testBody
	}