diff --git a/python/dune/codegen/sumfact/autotune.py b/python/dune/codegen/sumfact/autotune.py
index e73fd81a038b8e3ab79a48821fce7e3b4355c0ef..c77d8f0e94a5ddbc1354711c3d6fb6358d01a575 100644
--- a/python/dune/codegen/sumfact/autotune.py
+++ b/python/dune/codegen/sumfact/autotune.py
@@ -307,6 +307,10 @@ def generate_standalone_code(sf, filename):
 
 
 def generate_standalone_kernel_code(kernel, signature, filename, transformations=None):
+    # Turn off opcounting
+    opcounting = get_option("opcounter")
+    set_option("opcounter", False)
+
     with open(filename, 'w') as f:
         if transformations:
             f.write('// Transformations:\n')
@@ -417,6 +421,10 @@ def generate_standalone_kernel_code(kernel, signature, filename, transformations
                 'BENCHMARK_MAIN();']
         f.write('\n'.join(main))
 
+    # Maybe turn opcounting on again
+    set_option("opcounter", opcounting)
+
+
 
 def autotune_realization(sf=None, kernel=None, signature=None, transformations=None):
     """Generate an microbenchmark, compile run and return time