Rename LeapFrog to Leapfrog
[junction.git] / samples / MapPerformanceTests / TestAllMaps.py
1 #!/usr/bin/env python
2 import os
3 import subprocess
4 import sys
5
6 # Default CMake command is just 'cmake' but you can override it by setting
7 # the CMAKE environment variable:
8 CMAKE = os.getenv('CMAKE', 'cmake')
9
10 ALL_MAPS = [
11     ('null', 'junction/extra/impl/MapAdapter_Null.h', [], ['-i256', '-c10']),
12     ('michael', 'junction/extra/impl/MapAdapter_CDS_Michael.h', ['-DJUNCTION_WITH_CDS=1', '-DTURF_WITH_EXCEPTIONS=1'], ['-i256', '-c10']),
13     ('linear', 'junction/extra/impl/MapAdapter_Linear.h', [], ['-i256', '-c10']),
14     ('leapfrog', 'junction/extra/impl/MapAdapter_Leapfrog.h', [], ['-i256', '-c10']),
15     ('grampa', 'junction/extra/impl/MapAdapter_Grampa.h', [], ['-i256', '-c10']),
16     ('stdmap', 'junction/extra/impl/MapAdapter_StdMap.h', [], ['-i256', '-c10']),
17     ('folly', 'junction/extra/impl/MapAdapter_Folly.h', ['-DJUNCTION_WITH_FOLLY=1', '-DTURF_WITH_EXCEPTIONS=1'], ['-i256', '-c1']),
18     ('nbds', 'junction/extra/impl/MapAdapter_NBDS.h', ['-DJUNCTION_WITH_NBDS=1'], ['-i256', '-c10']),
19     ('tbb', 'junction/extra/impl/MapAdapter_TBB.h', ['-DJUNCTION_WITH_TBB=1'], ['-i256', '-c10']),
20     ('tervel', 'junction/extra/impl/MapAdapter_Tervel.h', ['-DJUNCTION_WITH_TERVEL=1'], ['-i256', '-c1']),
21 ]
22
23 # Scan arguments for path to CMakeLists.txt and args to pass through.
24 passThroughArgs = []
25 pathArgs = []
26 for arg in sys.argv[1:]:
27     if arg.startswith('-'):
28         passThroughArgs.append(arg)
29     else:
30         pathArgs.append(arg)
31 if len(pathArgs) != 1:
32     sys.stderr.write('You must provide exactly one path argument.\n')
33     exit(1)
34
35 listFilePath = os.path.abspath(pathArgs[0])
36 for suffix, include, cmakeOpts, runtimeOpts in ALL_MAPS:
37     subdir = 'build-%s' % suffix
38     if not os.path.exists(subdir):
39         os.mkdir(subdir)
40     os.chdir(subdir)
41     print('Configuring in %s...' % subdir)
42     with open('junction_userconfig.h.in', 'w') as f:
43         f.write('#define JUNCTION_IMPL_MAPADAPTER_PATH "%s"\n' % include)
44     userConfigCMakePath = os.path.abspath('junction_userconfig.h.in')
45     if os.sep != '/':
46         userConfigCMakePath = userConfigCMakePath.replace(os.sep, '/')
47     if subprocess.call([CMAKE, listFilePath, '-DCMAKE_INSTALL_PREFIX=TestAllMapsInstallFolder', '-DCMAKE_BUILD_TYPE=RelWithDebInfo', '-DTURF_USE_DLMALLOC=1', '-DTURF_DLMALLOC_FAST_STATS=1',
48                        '-DJUNCTION_USERCONFIG=%s' % userConfigCMakePath] + passThroughArgs + cmakeOpts) == 0:
49         subprocess.check_call([CMAKE, '--build', '.', '--target', 'install', '--config', 'RelWithDebInfo'])
50         print('Running in %s...' % subdir)
51         results = subprocess.check_output([os.path.join('TestAllMapsInstallFolder', 'bin', 'MapPerformanceTests')] + runtimeOpts)
52         with open('results.txt', 'wb') as f:
53             f.write(results)
54     os.chdir('..')