docs: def runprofile(mainfunction, output, timeout = 0, calibrate=False):
      '''
      Run the functions profiler and save the result
      If timeout is greater than 0, the profile will automatically stops after timeout seconds
      '''
      if noprofiler == True:
              print('ERROR: profiler and/or pstats library missing ! Please install it (probably package named python-profile) before running a profiling !')
              return False
      # This is the main function for profiling
      def _profile():
          profile.run(mainfunction, output)
      print('=> RUNNING FUNCTIONS PROFILER\n\n'); sys.stdout.flush();
      # Calibrate the profiler (only use this if the profiler produces some funny stuff, but calibration can also produce even more funny stuff with the latest cProfile of Python v2.7! So you should only enable calibration if necessary)
      if calibrate:
          print('Calibrating the profiler...'); sys.stdout.flush();
          cval = calibrateprofile()
          print('Calibration found value : %s' % cval); sys.stdout.flush();
      print('Initializing the profiler...'); sys.stdout.flush();
      # Run in timeout mode (if the function cannot ends by itself, this is the best mode: the function must ends for the profile to be saved)
      if timeout > 0:
          pthread = KThread(target=_profile) # we open the function with the profiler, in a special killable thread (see below why)
          print('Will now run the profiling and terminate it in %s seconds. Results will be saved in %s' % (str(timeout), str(output))); sys.stdout.flush();
          print('\nCountdown:'); sys.stdout.flush();
          for i in range(0,5):
                  print(str(5-i))
                  sys.stdout.flush()
                  time.sleep(1)
          print('0\nStarting to profile...'); sys.stdout.flush();
          pthread.start() # starting the thread
          time.sleep(float(timeout)) # after this amount of seconds, the thread gets killed and the profiler will end its job
          print('\n\nFinishing the profile and saving to the file %s' % str(output)); sys.stdout.flush();
          pthread.kill() # we must end the main function in order for the profiler to output its results (if we didn't launch a thread and just closed the process, it would have done no result)
      # Run in full length mode (we run the function until it ends)
      else:
          print("Running the profiler, please wait until the process terminates by itself (if you forcequit before, the profile won't be saved)")
          _profile()
      print('=> Functions Profile done !')
      return True