~linaro-toolchain-dev/cortex-strings/trunk

« back to all changes in this revision

Viewing changes to scripts/bench.py

  • Committer: Michael Hope
  • Date: 2012-06-12 03:33:40 UTC
  • Revision ID: michael.hope@linaro.org-20120612033340-p4ednk452cnshhts
Add a benchmark stub for memcmp.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# Prefix to the executables
18
18
build = '../build/try-'
19
19
 
20
 
ALL = 'memchr memcmp memcpy memset strchr strcmp strcpy strlen'
 
20
DEFAULTS = 'memcpy memset memchr strchr strcmp strcpy strlen'
21
21
 
22
22
HAS = {
23
 
    'this': 'bounce memchr memcpy memset strchr strcpy strlen',
24
 
    'bionic': 'memcmp memcpy memset strcmp strcpy strlen',
25
 
    'bionic-c': ALL,
26
 
    'csl': 'memcpy memset',
27
 
    'glibc': 'memcpy memset strlen',
28
 
    'glibc-c': ALL,
29
 
    'newlib': 'memcpy strcmp strcpy strlen',
30
 
    'newlib-c': ALL,
31
 
    'newlib-xscale': 'memchr memcpy memset strchr strcmp strcpy strlen',
 
23
    'this': 'bounce ' + DEFAULTS,
 
24
    'bionic': DEFAULTS,
 
25
    'glibc': DEFAULTS,
 
26
    'newlib': DEFAULTS,
 
27
    'newlib-xscale': DEFAULTS,
32
28
    'plain': 'memset memcpy strcmp strcpy',
 
29
    'csl': 'memcpy memset'
33
30
}
34
31
 
35
32
def run(cache, variant, function, bytes, loops, alignment=8, quiet=False):
110
107
    step1 = 2.0
111
108
    # Test intermediate powers of 1.4
112
109
    step2 = 1.4
 
110
 
 
111
    # Figure out how many steps get us up to the top
 
112
    steps1 = int(round(math.log(top) / math.log(step1)))
 
113
    steps2 = int(round(math.log(top) / math.log(step2)))
113
114
    
114
115
    bytes = []
115
 
    
116
 
    for step in [step1, step2]:
117
 
        if step:
118
 
            # Figure out how many steps get us up to the top
119
 
            steps = int(round(math.log(top) / math.log(step)))
120
 
            bytes.extend([int(step**x) for x in range(0, steps+1)])
 
116
    bytes.extend([int(step1**x) for x in range(0, steps1+1)])
 
117
    bytes.extend([int(step2**x) for x in range(0, steps2+1)])
121
118
 
122
119
    alignments = [8, 16, 4, 1, 2, 32]
123
120
 
141
138
        run_top(cache)
142
139
    finally:
143
140
        with open(cachename, 'w') as f:
144
 
            for line in sorted(cache.values()):
 
141
            for line in cache.values():
145
142
                print >> f, line
146
143
 
147
144
if __name__ == '__main__':