summary refs log tree commit diff stats
path: root/test/stuff/dirsize_benchmark.py
diff options
context:
space:
mode:
authorhut <hut@lavabit.com>2009-12-11 13:36:48 +0100
committerhut <hut@lavabit.com>2009-12-11 13:36:48 +0100
commitf58626842bbb2bd3f8446044a44a67180b737f4e (patch)
tree74ab897879a3b151488c8348759442396ef3336b /test/stuff/dirsize_benchmark.py
parent0c0b9489072922c0f597c7099f8728868ffbb4a4 (diff)
downloadranger-f58626842bbb2bd3f8446044a44a67180b737f4e.tar.gz
moved/fixed tests
Diffstat (limited to 'test/stuff/dirsize_benchmark.py')
-rw-r--r--test/stuff/dirsize_benchmark.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/stuff/dirsize_benchmark.py b/test/stuff/dirsize_benchmark.py
new file mode 100644
index 00000000..5784ee80
--- /dev/null
+++ b/test/stuff/dirsize_benchmark.py
@@ -0,0 +1,28 @@
+import os, time
+class Dirsize():
+	def a(path):
+		return len(os.listdir(path))
+
+	def b(path):
+		for _, dirs, files in os.walk(path):
+			return len(files) + len(dirs)
+
+	def c(path):
+		first = next(os.walk(path))
+		return len(first[1]) + len(first[2])
+
+paths = {
+		'/usr/lib': None,
+		'/usr/bin': None,
+		'/home/hut': None
+}
+
+for key in paths.keys():
+	paths[key] = Dirsize.a(key) # assume Dirsize.a() returns a correct result
+	for algo in ['a', 'b', 'c']:
+		t = time.time()
+		for i in range(4):
+			assert Dirsize.__dict__[algo](key) == paths[key]
+		print("algorithm %s: %20s: %f" % (algo, key, time.time() - t))
+
+# a !!
tle='author Kartik Agaram <vc@akkartik.com> 2018-07-27 17:07:52 -0700 committer Kartik Agaram <vc@akkartik.com> 2018-07-27 17:08:29 -0700 4447' href='/akkartik/mu/commit/html/066stream.mu.html?h=main&id=5fe060d582d4a82444243a28b18085c971a85628'>5fe060d5 ^
c762564b ^

805d58c6 ^

c842d90b ^





e5c11a51 ^






















c842d90b ^


e5c11a51 ^
c842d90b ^
204dae92 ^
b301e0c0 ^
204dae92 ^



b301e0c0 ^
204dae92 ^
4a48bedc ^
5fe060d5 ^
987b6304 ^




b301e0c0 ^
987b6304 ^
4a48bedc ^
987b6304 ^



b301e0c0 ^
987b6304 ^
4a48bedc ^
b301e0c0 ^
5fe060d5 ^
987b6304 ^




805d58c6 ^

5fe060d5 ^
987b6304 ^





b301e0c0 ^
987b6304 ^
4a48bedc ^
b301e0c0 ^
5fe060d5 ^
987b6304 ^




805d58c6 ^

5fe060d5 ^
987b6304 ^



b301e0c0 ^
987b6304 ^
4a48bedc ^
b301e0c0 ^
987b6304 ^


b301e0c0 ^
987b6304 ^




b301e0c0 ^
987b6304 ^
4a48bedc ^
b301e0c0 ^
987b6304 ^




c842d90b ^



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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144