Measure runtime of controller
975972
function (req, res, next) {
            if (!req.miajs.controllerDebugInfo) {
                req.miajs.controllerDebugInfo = {};
            }
            if (controller.name && controller.version) {
                req.miajs.controllerDebugInfo[controller.name + '_' + controller.version] = {'runtime': Date.now() - req.miajs.controllerStart};
            }
            next();
        }
972029
def controller_creatr(filename):
    """"""
    if not check():
        click.echo(Fore.RED + 'ERROR: Ensure you are in a bast app to run the create:controller command')
        return

    path = os.path.abspath('.') + '/controller'
    if not os.path.exists(path):
        os.makedirs(path)

    # if os.path.isfile(path + )

    file_name = str(filename + '.py')
    if os.path.isfile(path+"/" + file_name):
        click.echo(Fore.WHITE + Back.RED + "ERROR: Controller file exists")
        return
    controller_file = open(os.path.abspath('.') + '/controller/' + file_name, 'w+')
    compose = "from bast import Controller\n\nclass " + filename + "(Controller):\n    pass"
    controller_file.write(compose)
    controller_file.close()
    click.echo(Fore.GREEN + "Controller " + filename + " created successfully")
1306295
def elapsed(func):
    """"""

    @functools.wraps(func)
    def wrapper(*args, **kw):
        start = time.time()
        print('Running `%s()` ...' % func.__name__)
        res = func(*args, **kw)
        end = time.time()
        print('Function `%s()` running elapsed %.2f s' %
              (func.__name__, end - start))
        return res

    return wrapper
344309
def run(self):
        
        while True:
            data, sender = self.sock.recvfrom(1024)
            addr = sender[0]
            msg = data.decode('utf-8')
            if msg.startswith('/controller/'):
                try:
                    uid = msg.split('/')[2]
                    if uid == 'new':
                        port = int(msg.split('/')[3])
                        self._new_controller(addr, port)
                    else:
                        cmd = msg.split('/')[3]
                        if cmd == 'ping':
                            port = msg.split('/')[3]
                            self._ping(uid, addr, port)
                        elif cmd == 'kthxbye':
                            self._del_controller(uid)
                        elif cmd == 'states':
                            states = msg.split('/')[4]
                            self._update_states(uid, states)
                        elif cmd == 'text':
                            # /controller/<uid>/text/<text>
                            text = msg[12 + len(uid) + 6:]
                            self._got_message(uid, text)
                except IndexError or KeyError:
                    pass
            else:
                pass

            # find unused controllers and delete them
            ctlrs = self.controllers.items()
            for uid, state in ctlrs:
                if state[3] < time.time() - 60:
                    self.controllers.pop(uid)
47116
def runtime
      @runtime ||= ExecJS::ExternalRuntime.new(
        name:        'Node.js (V8)',
        command:     ['nodejs', 'node'],
        runner_path: File.expand_path('../runtime/runner.js', __FILE__)
        )
    end
962121
function rc(options, callback) {
  if(typeof options === 'function') {
    callback = options;
    options = null;
  }
  var r = new RunControl(options);
  if(typeof callback === 'function') r.load(callback);
  return r;
}
264267
def _print_installed_apps(self, controller):
        
        print('\nInstalled Sprockets %s Apps\n' % controller.upper())
        print("{0:<25} {1:>25}".format('Name', 'Module'))
        print(string.ljust('', 51, '-'))
        for app in self._get_applications(controller):
            print('{0:<25} {1:>25}'.format(app.name, '(%s)' % app.module_name))
        print('')
791713
function trackController (incoming, controller) {
    return incoming
        .withLatestFrom(controller)
        .flatMap(x => {

            const incomingEvent     = x[0];
            const currentController = x[1];

            /**
             * Controller has not been set, therefore we allow this event
             * through (as this will in turn cause the controller to be set)
             */
            if (currentController.id === '') {
                return just({locked: false, id: incomingEvent.id, socketId: incomingEvent.socketId});
            }

            /**
             * If the controller ID matches the incoming event ID
             * we return the controller, but re-set the socketId
             * as this could change (ie: every time the browser reloads)
             */
            if (currentController.id === incomingEvent.id) {
                return just(Object.assign(currentController, {socketId: incomingEvent.socketId}));
            }

            /**
             * If we reach here, the controller was set, but the
             * controller.id didn't match the incoming event.id. So we bail here
             * and don't pass any value through. This is how we essentially
             * ignore all events from any browser that is not currently deemed
             * the controller.
             */
            return empty();
        })
        .distinctUntilChanged();
}
1293149
def get_controller_state(self):
        """"""
        dpos = self.pos - self.last_pos
        self.last_pos = np.array(self.pos)
        return dict(
            dpos=dpos,
            rotation=self.rotation,
            grasp=int(self.grasp),
            reset=self._reset_state,
        )
25980
def controller_dirs
			parts = @controller.class.underscore.split('/').map do |part|
				%w[_controller _ctrl]
					.find { |suffix| part.chomp! suffix }
				part
				## Alternative, but slower by ~50%:
				# part.sub(/_(controller|ctrl)$/, '')
			end
			combine_parts(parts).map! { |path| path.join('/') }
		end
272243
def measure_time(func_to_measure):
    
    def wrap(*args, **kwargs):
        start_time = time()
        return_value = func_to_measure(*args, **kwargs)
        finish_time = time()
        log = "%s took %0.4f seconds. start_time = %0.4f - finish_time = %0.4f\n" % (func_to_measure.func_name,
                                                                                     finish_time - start_time,
                                                                                     start_time,
                                                                                     finish_time)
        print log
        return return_value
    return wrap
1270308
def x_runtime(f, *args, **kwargs):
    """"""

    _t0 = now()
    r = f(*args, **kwargs)
    _t1 = now()
    r.headers['X-Runtime'] = '{0}s'.format(Decimal(str(_t1 - _t0)))

    return r
248823
private static function checkController()
    {
        $bSetFallback = false;
        $sControllerNamespace = Configuration::read('application.namespace') . '\Controller\\' . self::getController();
        if (class_exists($sControllerNamespace) === false) {
            $bSetFallback = true;
        }
        if (method_exists($sControllerNamespace, self::getAction()) === false) {
            $bSetFallback = true;
        }
        if ($bSetFallback === true) {
            // Set controller
            $sFallbackController = RouteCollection::getFallbackController();
            self::setController($sFallbackController);
            // Set action to route action
            $sFallbackAction = RouteCollection::getFallbackAction();
            self::setAction($sFallbackAction);
            // Set action to route action
            $arsFallbackParameter = array('code' => 404);
            self::setParameter($arsFallbackParameter);
        }
    }
471497
private void processControllerClass(ClassDoc controller,
			Configuration configuration) {
		Tag[] controllerTagArray = controller.tags(WRTagTaglet.NAME);
		for (int i = 0; i < controllerTagArray.length; i++) {
			Set<String> controllerTags = WRTagTaglet
					.getTagSet(controllerTagArray[i].text());
			for (Iterator<String> iter = controllerTags.iterator(); iter
					.hasNext();) {
				String tag = iter.next();
				if (!this.taggedOpenAPIMethods.containsKey(tag)) {
					this.taggedOpenAPIMethods
							.put(tag, new HashSet<MethodDoc>());
				}
				// all action method of this controller should be processed
				// later.
				for (int j = 0; j < controller.methods().length; j++) {
					if (configuration.nodeprecated
							&& Util.isDeprecated(controller.methods()[j])) {
						continue;
					}
					if (isOpenAPIMethod(controller.methods()[j])) {
						this.taggedOpenAPIMethods.get(tag).add(
								controller.methods()[j]);
					}
				}
			}

			this.wrDoc.getWRTags().addAll(controllerTags);
		}
	}
626576
def get_running_time(self):
        
        if win32.PROCESS_ALL_ACCESS == win32.PROCESS_ALL_ACCESS_VISTA:
            dwAccess = win32.PROCESS_QUERY_LIMITED_INFORMATION
        else:
            dwAccess = win32.PROCESS_QUERY_INFORMATION
        hProcess = self.get_handle(dwAccess)
        (CreationTime, ExitTime, _, _) = win32.GetProcessTimes(hProcess)
        if self.is_alive():
            ExitTime = win32.GetSystemTimeAsFileTime()
        CreationTime = CreationTime.dwLowDateTime + (CreationTime.dwHighDateTime << 32)
        ExitTime     =     ExitTime.dwLowDateTime + (    ExitTime.dwHighDateTime << 32)
        RunningTime  = ExitTime - CreationTime
        return RunningTime / 10000
502919
def runtime(self):
        """"""
        if self._start_time is None:
            return self._run_time
        else:
            return self._run_time + (time.time() - self._start_time)
170363
function PIDController(options)
{
    // Options configuration
    this.opts       = {
        Kp         : 1.0,
        Ki         : 0.0,
        Kd         : 0.0,
        round      : true,
        Ts         : 1000,  // In MS. (Old sampleTime)
        uMin       : 0,
        uMax       : 255
    };

    options         = options || {};
    this.opts       = extend({}, this.opts, options);

    // Internal Use variables
    this.input           = function ()
    {
        // Function (Reading from sensor)
        this.setIVal(0);
    };

    this.direction       = 0;     // 0 = forward, 1 = drop down to and go forward, 3 = reverse
    this.duration        = 1;     // In seconds (How long to run - 0 = infinite)

    this.output          = function (val)
    {
        // Function (Writing to device)
        return val;
    };

    this.e          = [0.00, 0.00];
    this.PV         = [0.00, 0.00, 0.00];
    this.CO         = [0.00, 0.00];
    this.interval   = 0;
    this.iVal       = 0;
    this.running    = false;
    this.startTime  = 0;
    this.duration   = 0;
    this.SP         = 0;
    this.t1         = 0;
    this.timeLeft   = 0;
    this.tReached   = false;

    EventEmitter.call(this);
}