diff --git a/extras/benchmark/generate_benchmark.py b/extras/benchmark/generate_benchmark.py index 916d2f34..cee00179 100755 --- a/extras/benchmark/generate_benchmark.py +++ b/extras/benchmark/generate_benchmark.py @@ -79,6 +79,8 @@ def generate_benchmark( num_components_with_deps, num_deps, generate_runtime_bench_code, + use_exceptions=True, + use_rtti=True, fruit_build_dir=None, fruit_sources_dir=None, boost_di_sources_dir=None, @@ -129,6 +131,10 @@ def generate_benchmark( other_compile_flags = [] if generate_debuginfo: other_compile_flags.append('-g') + if not use_exceptions: + other_compile_flags.append('-fno-exceptions') + if not use_rtti: + other_compile_flags.append('-fno-rtti') compile_command = '%s -std=%s -MMD -MP -O2 -W -Wall -Werror -DNDEBUG -ftemplate-depth=10000 %s %s' % (compiler, cxx_std, include_flags, ' '.join(other_compile_flags)) link_command = '%s -std=%s -O2 -W -Wall -Werror %s %s' % (compiler, cxx_std, rpath_flags, library_dirs_flags) # GCC requires passing the -lfruit flag *after* all object files to be linked for some reason. @@ -165,6 +171,8 @@ def main(): parser.add_argument('--use-normalized-component', default='false', help='Set this to \'true\' to create a NormalizedComponent and create the injector from that. Only relevant when --di_library=fruit and --generate-runtime-bench-code=false.') parser.add_argument('--generate-runtime-bench-code', default='true', help='Set this to \'false\' for compile benchmarks.') parser.add_argument('--generate-debuginfo', default='false', help='Set this to \'true\' to generate debugging information (-g).') + parser.add_argument('--use-exceptions', default='true', help='Set this to \'false\' to disable exceptions.') + parser.add_argument('--use-rtti', default='true', help='Set this to \'false\' to disable RTTI.') args = parser.parse_args() @@ -206,7 +214,9 @@ def main(): use_new_delete=(args.use_new_delete == 'true'), use_interfaces=(args.use_interfaces == 'true'), use_normalized_component=(args.use_normalized_component == 'true'), - generate_runtime_bench_code=(args.generate_runtime_bench_code == 'true')) + generate_runtime_bench_code=(args.generate_runtime_bench_code == 'true'), + use_exceptions=(args.use_exceptions == 'true'), + use_rtti=(args.use_rtti == 'true')) if __name__ == "__main__": diff --git a/extras/benchmark/run_benchmarks.py b/extras/benchmark/run_benchmarks.py index 21825a39..449d81d2 100755 --- a/extras/benchmark/run_benchmarks.py +++ b/extras/benchmark/run_benchmarks.py @@ -374,6 +374,13 @@ def prepare(self): def run(self): return self.run_executable_size_benchmark() +# This is not really a 'benchmark', but we consider it as such to reuse the benchmark infrastructure. +class ExecutableSizeBenchmarkWithoutExceptionsAndRtti(ExecutableSizeBenchmark): + def __init__(self, **kwargs): + super().__init__(use_exceptions=False, + use_rtti=False, + **kwargs) + class FruitCompileTimeBenchmark(CompileTimeBenchmark): def __init__(self, fruit_sources_dir, **kwargs): super().__init__(di_library='fruit', @@ -415,6 +422,13 @@ def __init__(self, fruit_sources_dir, **kwargs): fruit_sources_dir=fruit_sources_dir, **kwargs) +# This is not really a 'benchmark', but we consider it as such to reuse the benchmark infrastructure. +class FruitExecutableSizeBenchmarkWithoutExceptionsAndRtti(ExecutableSizeBenchmarkWithoutExceptionsAndRtti): + def __init__(self, fruit_sources_dir, **kwargs): + super().__init__(di_library='fruit', + path_to_code_under_test=fruit_sources_dir, + fruit_sources_dir=fruit_sources_dir, + **kwargs) class BoostDiCompileTimeBenchmark(CompileTimeBenchmark): def __init__(self, boost_di_sources_dir, **kwargs): @@ -452,6 +466,14 @@ def __init__(self, boost_di_sources_dir, **kwargs): boost_di_sources_dir=boost_di_sources_dir, **kwargs) +# This is not really a 'benchmark', but we consider it as such to reuse the benchmark infrastructure. +class BoostDiExecutableSizeBenchmarkWithoutExceptionsAndRtti(ExecutableSizeBenchmarkWithoutExceptionsAndRtti): + def __init__(self, boost_di_sources_dir, **kwargs): + super().__init__(di_library='boost_di', + path_to_code_under_test=boost_di_sources_dir, + boost_di_sources_dir=boost_di_sources_dir, + **kwargs) + class SimpleDiCompileTimeBenchmark(CompileTimeBenchmark): def __init__(self, **kwargs): super().__init__(di_library='none', @@ -478,6 +500,12 @@ def __init__(self, **kwargs): super().__init__(di_library='none', **kwargs) +# This is not really a 'benchmark', but we consider it as such to reuse the benchmark infrastructure. +class SimpleDiExecutableSizeBenchmarkWithoutExceptionsAndRtti(ExecutableSizeBenchmarkWithoutExceptionsAndRtti): + def __init__(self, **kwargs): + super().__init__(di_library='none', + **kwargs) + class SimpleDiWithInterfacesCompileTimeBenchmark(SimpleDiCompileTimeBenchmark): def __init__(self, **kwargs): super().__init__(use_interfaces=True, **kwargs) @@ -499,6 +527,11 @@ class SimpleDiWithInterfacesExecutableSizeBenchmark(SimpleDiExecutableSizeBenchm def __init__(self, **kwargs): super().__init__(use_interfaces=True, **kwargs) +# This is not really a 'benchmark', but we consider it as such to reuse the benchmark infrastructure. +class SimpleDiWithInterfacesExecutableSizeBenchmarkWithoutExceptionsAndRtti(SimpleDiExecutableSizeBenchmarkWithoutExceptionsAndRtti): + def __init__(self, **kwargs): + super().__init__(use_interfaces=True, **kwargs) + class SimpleDiWithInterfacesAndNewDeleteCompileTimeBenchmark(SimpleDiWithInterfacesCompileTimeBenchmark): def __init__(self, **kwargs): super().__init__(use_new_delete=True, **kwargs) @@ -520,6 +553,11 @@ class SimpleDiWithInterfacesAndNewDeleteExecutableSizeBenchmark(SimpleDiWithInte def __init__(self, **kwargs): super().__init__(use_new_delete=True, **kwargs) +# This is not really a 'benchmark', but we consider it as such to reuse the benchmark infrastructure. +class SimpleDiWithInterfacesAndNewDeleteExecutableSizeBenchmarkWithoutExceptionsAndRtti(SimpleDiWithInterfacesExecutableSizeBenchmarkWithoutExceptionsAndRtti): + def __init__(self, **kwargs): + super().__init__(use_new_delete=True, **kwargs) + def round_to_significant_digits(n, num_significant_digits): if n <= 0: @@ -711,6 +749,7 @@ def main(): 'fruit_startup_time': FruitStartupTimeBenchmark, 'fruit_startup_time_with_normalized_component': FruitStartupTimeWithNormalizedComponentBenchmark, 'fruit_executable_size': FruitExecutableSizeBenchmark, + 'fruit_executable_size_without_exceptions_and_rtti': FruitExecutableSizeBenchmarkWithoutExceptionsAndRtti, }[benchmark_name] benchmark = benchmark_class( benchmark_definition=benchmark_definition, @@ -723,6 +762,7 @@ def main(): 'boost_di_run_time': BoostDiRunTimeBenchmark, 'boost_di_startup_time': BoostDiStartupTimeBenchmark, 'boost_di_executable_size': BoostDiExecutableSizeBenchmark, + 'boost_di_executable_size_without_exceptions_and_rtti': BoostDiExecutableSizeBenchmarkWithoutExceptionsAndRtti, }[benchmark_name] benchmark = benchmark_class( benchmark_definition=benchmark_definition, @@ -734,16 +774,19 @@ def main(): 'simple_di_run_time': SimpleDiRunTimeBenchmark, 'simple_di_startup_time': SimpleDiStartupTimeBenchmark, 'simple_di_executable_size': SimpleDiExecutableSizeBenchmark, + 'simple_di_executable_size_without_exceptions_and_rtti': SimpleDiExecutableSizeBenchmarkWithoutExceptionsAndRtti, 'simple_di_with_interfaces_compile_time': SimpleDiWithInterfacesCompileTimeBenchmark, 'simple_di_with_interfaces_incremental_compile_time': SimpleDiWithInterfacesIncrementalCompileTimeBenchmark, 'simple_di_with_interfaces_run_time': SimpleDiWithInterfacesRunTimeBenchmark, 'simple_di_with_interfaces_startup_time': SimpleDiWithInterfacesStartupTimeBenchmark, 'simple_di_with_interfaces_executable_size': SimpleDiWithInterfacesExecutableSizeBenchmark, + 'simple_di_with_interfaces_executable_size_without_exceptions_and_rtti': SimpleDiWithInterfacesExecutableSizeBenchmarkWithoutExceptionsAndRtti, 'simple_di_with_interfaces_and_new_delete_compile_time': SimpleDiWithInterfacesAndNewDeleteCompileTimeBenchmark, 'simple_di_with_interfaces_and_new_delete_incremental_compile_time': SimpleDiWithInterfacesAndNewDeleteIncrementalCompileTimeBenchmark, 'simple_di_with_interfaces_and_new_delete_run_time': SimpleDiWithInterfacesAndNewDeleteRunTimeBenchmark, 'simple_di_with_interfaces_and_new_delete_startup_time': SimpleDiWithInterfacesAndNewDeleteStartupTimeBenchmark, 'simple_di_with_interfaces_and_new_delete_executable_size': SimpleDiWithInterfacesAndNewDeleteExecutableSizeBenchmark, + 'simple_di_with_interfaces_and_new_delete_executable_size_without_exceptions_and_rtti': SimpleDiWithInterfacesAndNewDeleteExecutableSizeBenchmarkWithoutExceptionsAndRtti, }[benchmark_name] benchmark = benchmark_class( benchmark_definition=benchmark_definition)