예제 #1
0
    def _debug_profile_userEnterCommand(self):
        """
        Debug menu command for profiling userEnterCommand(commandName).

        This creates a profile.output file on each use
        (replacing a prior one if any, even if it was created
        during the same session).

        Note that for some commands, a lot more work will be done the
        first time they are entered during a session (or in some cases,
        the first time since opening a new file) than in subsequent times.
        """
        # Ninad 2008-10-03; renamed/revised by bruce 090305
        
        RECOGNIZED_COMMAND_NAMES = (
            'DEPOSIT', 
            'BUILD_DNA', 
            'DNA_SEGMENT', 
            'DNA_STRAND',
            'CRYSTAL', 
            'BUILD_NANOTUBE', 
            'EDIT_NANOTUBE',
            'EXTRUDE', 
            'MODIFY',
            'MOVIE'
         )
        
        ok, commandName =  grab_text_line_using_dialog(
            title = "profile entering given command", 
            label = "Enter the command.commandName e.g. 'BUILD_DNA' , 'DEPOSIT'"
         )
        if not ok:
            print "No command name entered, returning"
            return
        
        commandName = str(commandName)
        commandName = commandName.upper()
        if not commandName in RECOGNIZED_COMMAND_NAMES:
            #bruce 090305 changed this to just a warning, added try/except
            print "Warning: command name %r might or might not work. " \
                  "Trying it anyway." % (commandName,)
            pass 
        
        print "Profiling command enter for %s" % (commandName,)
                 
        win = self._debug_win
        meth = self.win.commandSequencer.userEnterCommand
        set_enabled_for_profile_single_call(True)
        tm0 = clock()
        try:
            profile_single_call_if_enabled(meth, commandName)
        except:
            print "exception entering command caught and discarded." #e improve
            sys.stdout.flush()
            pass
        tm1 = clock()
        set_enabled_for_profile_single_call(False)
        print "Profiling complete. Total CPU time to enter %s = %s" % \
              (commandName, (tm1 - tm0))
        return
예제 #2
0
    def _debug_profile_userEnterCommand(self):
        """
        Debug menu command for profiling userEnterCommand(commandName).

        This creates a profile.output file on each use
        (replacing a prior one if any, even if it was created
        during the same session).

        Note that for some commands, a lot more work will be done the
        first time they are entered during a session (or in some cases,
        the first time since opening a new file) than in subsequent times.
        """
        # Ninad 2008-10-03; renamed/revised by bruce 090305

        RECOGNIZED_COMMAND_NAMES = ('DEPOSIT', 'BUILD_DNA', 'DNA_SEGMENT',
                                    'DNA_STRAND', 'CRYSTAL', 'BUILD_NANOTUBE',
                                    'EDIT_NANOTUBE', 'EXTRUDE', 'MODIFY',
                                    'MOVIE')

        ok, commandName = grab_text_line_using_dialog(
            title="profile entering given command",
            label="Enter the command.commandName e.g. 'BUILD_DNA' , 'DEPOSIT'")
        if not ok:
            print "No command name entered, returning"
            return

        commandName = str(commandName)
        commandName = commandName.upper()
        if not commandName in RECOGNIZED_COMMAND_NAMES:
            #bruce 090305 changed this to just a warning, added try/except
            print "Warning: command name %r might or might not work. " \
                  "Trying it anyway." % (commandName,)
            pass

        print "Profiling command enter for %s" % (commandName, )

        win = self._debug_win
        meth = self.win.commandSequencer.userEnterCommand
        set_enabled_for_profile_single_call(True)
        tm0 = clock()
        try:
            profile_single_call_if_enabled(meth, commandName)
        except:
            print "exception entering command caught and discarded."  #e improve
            sys.stdout.flush()
            pass
        tm1 = clock()
        set_enabled_for_profile_single_call(False)
        print "Profiling complete. Total CPU time to enter %s = %s" % \
              (commandName, (tm1 - tm0))
        return
예제 #3
0
    def _debug_do_benchmark(self):
        # simple graphics benchmark, piotr 080311
        from time import clock
        print "Entering graphics benchmark. Drawing 100 frames... please wait."
        win = self._debug_win
        self.win.resize(1024, 768)  # resize the window to a constant size

        self.win.glpane.paintGL()
        # draw once just to make sure the GL context is current
        # piotr 080405
        # [BUG: the right way is gl_update -- direct call of paintGL won't
        #  always work, context might not be current -- bruce 090305 comment]

        env.call_qApp_processEvents()  # make sure all events were processed
        tm0 = clock()
        profile_single_call_if_enabled(self._draw_hundred_frames, self, None)
        tm1 = clock()
        print "Benchmark complete. FPS = ", 100.0 / (tm1 - tm0)
        return
예제 #4
0
 def _debug_do_benchmark(self):
     # simple graphics benchmark, piotr 080311
     from time import clock
     print "Entering graphics benchmark. Drawing 100 frames... please wait."
     win = self._debug_win
     self.win.resize(1024,768) # resize the window to a constant size
     
     self.win.glpane.paintGL() 
     # draw once just to make sure the GL context is current
     # piotr 080405
     # [BUG: the right way is gl_update -- direct call of paintGL won't
     #  always work, context might not be current -- bruce 090305 comment]
     
     env.call_qApp_processEvents() # make sure all events were processed
     tm0 = clock()
     profile_single_call_if_enabled(self._draw_hundred_frames, self, None)
     tm1 = clock()
     print "Benchmark complete. FPS = ", 100.0 / (tm1 - tm0)
     return