Total time of this session.

    Reports the time elapsed from the construction of the `Stats` object to
    this `submit()` call.

    This is a flag you can pass to `Stats.submit()`.
348584
def SESSION_TIME(stats, info):
    
    duration = time.time() - stats.started_time
    secs = int(duration)
    msecs = int((duration - secs) * 1000)
    info.append(('session_time', '%d.%d' % (secs, msecs)))
25042
def total_duration(self):
        
        durations = [result.duration for result in self.data]
        return sum(durations)
784392
def _post_stats(self, stats):
        '''
        
        '''
        end_time = time.time()
        if end_time - self.stat_clock > self.opts['master_stats_event_iter']:
            # Fire the event with the stats and wipe the tracker
            self.aes_funcs.event.fire_event({'time': end_time - self.stat_clock, 'worker': self.name, 'stats': stats}, tagify(self.name, 'stats'))
            self.stats = collections.defaultdict(lambda: {'mean': 0, 'latency': 0, 'runs': 0})
            self.stat_clock = end_time
1285557
def update(self,
               stats,
               duration=3):
        
        # Build the stats list
        line = ''
        for plugin, attribute in self.plugins_list:
            # Check if the plugin exist and is enable
            if plugin in stats.getPluginsList() and \
               stats.get_plugin(plugin).is_enable():
                stat = stats.get_plugin(plugin).get_export()
            else:
                continue

            # Build the line to display (header or data)
            if self.header:
                line += self.build_header(plugin, attribute, stat)
            else:
                line += self.build_data(plugin, attribute, stat)

        # Display the line (without the last 'separator')
        printandflush(line[:-1])

        # Display header one time
        self.header = False

        # Wait until next refresh
        if duration > 0:
            time.sleep(duration)
792989
def _requires_submission(self):
        
        if self.dbcon_part is None:
            return False

        tables = get_table_list(self.dbcon_part)
        nrows = 0
        for table in tables:
            if table == '__submissions__':
                continue
            nrows += get_number_of_rows(self.dbcon_part, table)
        if nrows:
            logger.debug('%d new statistics were added since the last submission.' % nrows)
        else:
            logger.debug('No new statistics were added since the last submission.')

        t0 = datetime.datetime.now()
        s = self['__submissions__']
        last_submission = s.get_last(1)
        if last_submission:
            logger.debug('Last submission was %s' % last_submission[0]['Time'])
            t_ref = datetime.datetime.strptime(last_submission[0]['Time'], Table.time_fmt)
        else:
            t_ref = datetime.datetime.fromtimestamp(os.path.getmtime(self.filepath))

        submission_interval_passed = (t0 - t_ref).total_seconds() > self.submit_interval_s
        submission_required = bool(submission_interval_passed and nrows)
        if submission_required:
            logger.debug('A submission is overdue.')
        else:
            logger.debug('No submission required.')
        return submission_required
325411
def interevent_time(records):
    
    inter_events = pairwise(r.datetime for r in records)
    inter = [(new - old).total_seconds() for old, new in inter_events]

    return summary_stats(inter)
636007
def CreateSessionCompletion(self):
    
    self.completion_time = int(time.time() * 1000000)

    session_completion = SessionCompletion()
    session_completion.aborted = self.aborted
    session_completion.analysis_reports_counter = self.analysis_reports_counter
    session_completion.event_labels_counter = self.event_labels_counter
    session_completion.identifier = self.identifier
    session_completion.parsers_counter = self.parsers_counter
    session_completion.timestamp = self.completion_time
    return session_completion
158911
void dumpStats() {
        long wallTimeNanos = totalStopwatch.elapsed(TimeUnit.NANOSECONDS);
        long dbtime = 0;
        for (String name : methodCalls.keySet()) {
            long calls = methodCalls.get(name);
            long time = methodTotalTime.get(name);
            dbtime += time;
            long average = time / calls;
            double proportion = (time + 0.0) / (wallTimeNanos + 0.0);
            log.info(name + " c:" + calls + " r:" + time + " a:" + average + " p:" + String.format("%.2f", proportion));
        }
        double dbproportion = (dbtime + 0.0) / (wallTimeNanos + 0.0);
        double hitrate = (hit + 0.0) / (hit + miss + 0.0);
        log.info("Cache size:" + utxoCache.size() + " hit:" + hit + " miss:" + miss + " rate:"
                + String.format("%.2f", hitrate));
        bloom.printStat();
        log.info("hasTxOut call:" + hasCall + " True:" + hasTrue + " False:" + hasFalse);
        log.info("Wall:" + totalStopwatch + " percent:" + String.format("%.2f", dbproportion));
        String stats = db.getProperty("leveldb.stats");
        System.out.println(stats);

    }
769910
public function addTimestampValidation() {
        // Add timestamp-based spam counter-measure
        $this->addElement(
            'hidden', self::TIMESTAMP_FIELD_KEY, array(
            'validators' => array(new Garp_Validate_Duration)
            )
        );
        // If the form is submitted, do not set the value.
        if (!$this->getValue(self::TIMESTAMP_FIELD_KEY)) {
            $now = time();
            $this->getElement(self::TIMESTAMP_FIELD_KEY)->setValue($now);
        }
    }
474797
def _print_stats(self, env, stats):
        

        def _format_time(mins):
            """ Generates formatted time string.
                """
            mins = int(mins)

            if mins < MINS_IN_HOUR:
                time_str = '0:{0:02}'.format(mins)
            else:
                hours = mins // MINS_IN_HOUR
                mins %= MINS_IN_HOUR

                if mins > 0:
                    time_str = '{0}:{1:02}'.format(hours, mins)
                else:
                    time_str = '{0}'.format(hours)

            return time_str

        if not stats:
            env.io.write('No stats found.')
            return

        for date, tasks in stats:
            env.io.write('')
            total_mins = float(sum(v[1] for v in tasks))
            env.io.write('[ {0} ]'.format(date.strftime('%Y-%m-%d')))
            env.io.write('')

            for name, mins in tasks:
                # format time
                time_str = _format_time(mins)

                # generate stat line
                line = '   {0:>5}'.format(time_str)
                line += ' ({0:2.0f}%) - '.format(mins * 100.0 / total_mins)
                if len(name) > 55:
                    name = name[:55] + '...'
                line += name
                env.io.write(line)

            # generate total line
            env.io.write('_' * len(line))
            time_str = _format_time(total_mins)
            env.io.write('   {0:>5} (total)'.format(time_str))
            env.io.write('')
920409
def _timedelta_total_seconds(td):
    
    if hasattr(timedelta, "total_seconds"):
        return getattr(td, "total_seconds")()

    # Python 2.6 backward compatibility
    return (td.microseconds + (td.seconds + td.days * 24 * 3600) * 10**6) / float(10**6)
1159632
def submit_statistics(self):
        
        if not self._hq.get('api_key', False) or not self._enabled:
            return
        for r in ('uuid', 'application_name', 'application_version'):
            if not getattr(self, r, False):
                return False
        self['__submissions__'] += 1

        try:
            # To ensure the usage tracker does not interfere with script functionality, catch all exceptions so any
            # errors always exit nicely.
            tableinfo = self.get_table_info()
            # Get the last row from each table
            json_data = database_to_json(self.dbcon_master, tableinfo)
            json_data.update(database_to_json(self.dbcon_part, tableinfo))

            payload = {'API Key': self._hq['api_key'],
                       'User Identifier': self.uuid,
                       'Application Name': self.application_name,
                       'Application Version': self.application_version,
                       'Data': json_data
                       }

            # For tables with data that has not yet been writen to the database (ie inital values),
            # add them manually to the payload
            for name, info in tableinfo.iteritems():
                if name not in payload['Data']:
                    table = self[name]
                    if table is None:
                        continue
                    if isinstance(table, State):
                        data = 'No State' if table._state == NO_STATE else table._state
                    else:
                        data = table.count
                    tableinfo[name]['data'] = data
                    payload['Data'][name] = tableinfo[name]

            try:
                response = requests.post(self._hq['host'] + '/usagestats/upload',
                                         data=json.dumps(payload),
                                         timeout=self.HQ_DEFAULT_TIMEOUT)
            except Exception as e:
                logging.error(e)
                response = False

            if response and response.status_code == 200:
                success = True
                logger.debug('Submission to %s successful.' % self._hq['host'])
            else:
                success = False

            # If we have a partial database, merge it into the local master and create a new partial
            if self.dbcon_part and success:
                merge_databases(self.dbcon_master, self.dbcon_part)

                # Clear the partial database now that the stats have been uploaded
                for table in get_table_list(self.dbcon_part):
                    clear_table(self.dbcon_part, table)

            return success
        except Exception as e:
            logger.error(e)
            self['__submissions__'].delete_last()
            self.stop_watcher()
            return False
656749
def get(self):
        """"""
        elapsed = datetime.now() - self._previous
        self._previous += elapsed
        return elapsed.total_seconds()
1000159
public void recordGetTime(long timeNS, boolean emptyResponse, long totalBytes, long keyBytes) {
        recordTime(Tracked.GET, timeNS, emptyResponse ? 1 : 0, totalBytes, keyBytes, 0);
    }
1259857
def submit(self):
        
        futures = []
        while self.submitted < 4 and not self.done():
            part = self.parts.pop(0)
            futures.append(
                self.pool.submit(
                    _download_part, self.file_path, self.session, self.url,
                    self.retry, self.timeout, *part)
            )
            self.submitted += 1
            self.total_submitted += 1

        return futures
1353820
def getUptime(self):
        
        try:
            fp = open(uptimeFile, 'r')
            line = fp.readline()
            fp.close()
        except:
            raise IOError('Failed reading stats from file: %s' % uptimeFile)
        return float(line.split()[0])
170556
def report(output)
      output.title(options[:title]) if options[:title]

      if @last > 0 && @first < 99_999_999_999_999
        output.with_style(cell_separator: false) do
          output.table({ width: 20 }, {}) do |rows|
            rows << ['First request:', first_timestamp.strftime('%Y-%m-%d %H:%M:%I')]
            rows << ['Last request:',  last_timestamp.strftime('%Y-%m-%d %H:%M:%I')]
            rows << ['Total time analyzed:', "#{timespan.ceil} days"]
          end
        end
      end
    end