diff --git a/src/ModFile.cc b/src/ModFile.cc
index 123a17650f380420949392fcdbc74e24a9be7ac6..65e8f69cc7fe43d1083191c9854cb395e10faabd 100644
--- a/src/ModFile.cc
+++ b/src/ModFile.cc
@@ -1075,6 +1075,11 @@ ModFile::writeMOutput(const string &basename, bool clear_all, bool clear_global,
             static_model.writeAuxVarInitval(mOutputFile, ExprNodeOutputType::matlabOutsideModel);
         }
 
+      if (!notime)
+          mOutputFile << endl << endl
+                      << "oo_.time = toc(tic0);" << endl
+                      << "disp(['Total computing time : ' dynsec2hms(oo_.time) ]);" << endl;
+
       mOutputFile << "save('" << basename << "_results.mat', 'oo_', 'M_', 'options_');" << endl
                   << "if exist('estim_params_', 'var') == 1" << endl
                   << "  save('" << basename << "_results.mat', 'estim_params_', '-append');" << endl << "end" << endl
@@ -1091,11 +1096,6 @@ ModFile::writeMOutput(const string &basename, bool clear_all, bool clear_global,
 
       config_file.writeEndParallel(mOutputFile);
 
-      if (!notime)
-          mOutputFile << endl << endl
-                      << "oo_.time = toc(tic0);" << endl
-                      << "disp(['Total computing time : ' dynsec2hms(oo_.time) ]);" << endl;
-
       if (!no_warn)
         {
           if (warnings.countWarnings() > 0)