Aggregate an event for the whole profile.
979385
def aggregate(self, event):
        """"""

        total = event.null()
        for function in compat_itervalues(self.functions):
            try:
                total = event.aggregate(total, function[event])
            except UndefinedEvent:
                return
        self[event] = total
704290
def all(klass, account, tailored_audience_id, **kwargs):
        """"""

        resource = klass.RESOURCE_COLLECTION.format(
            account_id=account.id,
            tailored_audience_id=tailored_audience_id)
        request = Request(account.client, 'get', resource, params=kwargs)

        return Cursor(klass, request, init_with=[account])
527790
def basic_event_table(event):
    """"""
    table = formatting.Table(["Id", "Status", "Type", "Start", "End"],
                             title=utils.clean_splitlines(event.get('subject')))

    table.add_row([
        event.get('id'),
        utils.lookup(event, 'statusCode', 'name'),
        utils.lookup(event, 'notificationOccurrenceEventType', 'keyName'),
        utils.clean_time(event.get('startDate')),
        utils.clean_time(event.get('endDate'))
    ])

    return table
386361
def _event(self, event):
    """"""
    result = dict(
        pid=event.device_id,
        tid=event.resource_id,
        name=event.name,
        ts=event.timestamp_ps / 1000000.0)
    if event.duration_ps:
      result['ph'] = _TYPE_COMPLETE
      result['dur'] = event.duration_ps / 1000000.0
    else:
      result['ph'] = _TYPE_INSTANT
      result['s'] = _SCOPE_THREAD
    for key in dict(event.args):
      if 'args' not in result:
        result['args'] = {}
      result['args'][key] = event.args[key]
    return result
800087
function formatProfileData(profileData) {
  var profile;
  if (profileData) {
    profile = extractAttributeFields(profileData.attributes);
    profile.username = profileData.username;
    profile.email = profileData.email;
  }
  return profile;
}
1329950
def appliesToEvent(self, event):
        '''  '''
        return (
            event in self.individualEvents.all() or
            event.session in self.eventSessions.all() or
            event.category in self.seriesCategories.all() or
            event.category in self.eventCategories.all()
        )
1051527
def profile():
    """"""
    # Create forms
    verification_form = VerificationForm(formdata=None, prefix="verification")
    profile_form = profile_form_factory()

    # Process forms
    form = request.form.get('submit', None)
    if form == 'profile':
        handle_profile_form(profile_form)
    elif form == 'verification':
        handle_verification_form(verification_form)

    return render_template(
        current_app.config['USERPROFILES_PROFILE_TEMPLATE'],
        profile_form=profile_form,
        verification_form=verification_form,)
1115728
void onEvent(Device device, ProfilingEvent event) {
	  if (event == null) {
		  logger.log(Level.WARNING, "Discarding profiling event " + event + " for null device, for Kernel class: " + kernelClass.getName());
		  return;
	  }
	  final KernelDeviceProfile deviceProfile = deviceProfiles.get(device);
      switch (event) {
         case CLASS_MODEL_BUILT: // fallthrough
         case OPENCL_GENERATED:  // fallthrough
         case INIT_JNI:          // fallthrough
         case OPENCL_COMPILED:   // fallthrough
         case PREPARE_EXECUTE:   // fallthrough
         case EXECUTED:          // fallthrough
         {
            if (deviceProfile == null) {
               logger.log(Level.SEVERE, "Error in KernelProfile, no currentDevice (synchronization error?");
            }
            deviceProfile.onEvent(event);
            break;
         }
         case START:
            throw new IllegalArgumentException("must use onStart(Device) to start profiling");
         default:
            throw new IllegalArgumentException("Unhandled event " + event);
      }
   }
47885
def CreateEventMetadata(metric_name,
                        bins=None,
                        fields=None,
                        docstring=None,
                        units=None):
  """"""
  return rdf_stats.MetricMetadata(
      varname=metric_name,
      bins=bins or [],
      metric_type=rdf_stats.MetricMetadata.MetricType.EVENT,
      value_type=rdf_stats.MetricMetadata.ValueType.DISTRIBUTION,
      fields_defs=FieldDefinitionProtosFromTuples(fields or []),
      docstring=docstring,
      units=units)
536854
protected function _loadEsiCacheClearEvents() {
        Varien_Profiler::start('turpentine::helper::esi::_loadEsiCacheClearEvents');
        $layoutXml = $this->getLayoutXml();
        $events = $layoutXml->xpath(
            '//action[@method=\'setEsiOptions\']/params/flush_events/*' );
        if ($events) {
            $events = array_unique(array_map(
                create_function('$e',
                    'return (string)$e->getName();'),
                $events ));
        } else {
            $events = array();
        }
        Varien_Profiler::stop('turpentine::helper::esi::_loadEsiCacheClearEvents');
        return $events;
    }
514826
def filter_events(cls, client, event_data):
        """"""

        for event in cls.events:
            # try event filters
            if event.matches(client, event_data):
                yield event
559887
function(name, force, callback) {
    var err = null;
    var profiles = this.all();

    if (~profiles.indexOf(name)) {
      err = 'Profile "' + name + '" already exists.';

    } else if (!force && ~RESERVED_PROFILE_NAME.indexOf(name)) {
      err = 'Profile name "' + name + '" is reserved by `multi-profile`';

    } else if (/^_/.test(name)) {
      err = 'Profile name "' + name + '" should not begin with `_`';

    } else {
      profiles.push(name);
      this.attr.set('profiles', profiles);
    }

    var data = {
      err: err,
      name: name
    };
    this.emit('add', data);

    callback && callback(err, data);
  }
1098992
def run(self):
        """"""
        if ProfileCollection and isinstance(self.mloginfo.logfile,
                                            ProfileCollection):
            print("\n    not available for system.profile collections\n")
            return

        for version, logevent in self.mloginfo.logfile.restarts:
            print("   %s version %s"
                  % (logevent.datetime.strftime("%b %d %H:%M:%S"), version))

        if len(self.mloginfo.logfile.restarts) == 0:
            print("  no restarts found")
914085
def report(self):
        """"""
        timestamp = time.time()
        cutoff = timestamp - self.period
        truncate = 0
        summary = {}
        for event in self.status_history[:-1]:
            if event["end"] < cutoff:
                truncate = truncate + 1
                continue
            summary[event["status"]] = (
                summary.get(event["status"], 0)
                + event["end"]
                - max(cutoff, event["start"])
            )
        summary[self.status_history[-1]["status"]] = (
            summary.get(self.status_history[-1]["status"], 0)
            + timestamp
            - max(cutoff, self.status_history[-1]["start"])
        )
        if truncate:
            self.status_history = self.status_history[truncate:]
        total_duration = sum(summary.values())
        summary = {s: round(d / total_duration, 4) for s, d in summary.items()}
        return summary
1160259
public Set<IoEventType> getEventsToProfile() {
        Set<IoEventType> set = new HashSet<>();
        
        if ( profileMessageReceived ) {
            set.add(IoEventType.MESSAGE_RECEIVED);
        }
        
        if ( profileMessageSent) {
            set.add(IoEventType.MESSAGE_SENT);
        }
        
        if ( profileSessionCreated ) {
            set.add(IoEventType.SESSION_CREATED);
        }
        
        if ( profileSessionOpened ) {
            set.add(IoEventType.SESSION_OPENED);
        }
        
        if ( profileSessionIdle ) {
            set.add(IoEventType.SESSION_IDLE);
        }
        
        if ( profileSessionClosed ) {
            set.add(IoEventType.SESSION_CLOSED);
        }
        
        return set;
    }
95392
function mark(markName) {
            if (enabled) {
                marks[markName] = ts.timestamp();
                counts[markName] = (counts[markName] || 0) + 1;
                profilerEvent(markName);
            }
        }
456389
public function render() {
		$totalEvents = $this->getTotalEvents();
		
		if ($totalEvents > 0) {
			$text  = 'Total: ' . $totalEvents . ' events in: ';
			$text .= round($this->getTotalElapsedTime(), 4) . 's ';
		} else {
			$text = 'No events';
		}
		
		$text .= PHP_EOL;
		
		$info = $this->getAdditionalInfo();
		
		if ($info !== null) {
			$text .= PHP_EOL;
			$text .= 'Info:' . PHP_EOL;
			
			if (is_string($info)) {
				$text .= $info . PHP_EOL;
			} else if (is_array($info)) {
				foreach ($info as $key => $part) {
					$text .= $key . ': ' . $part . PHP_EOL;
				}
			}
		}
		
		if ($totalEvents > 0) {
			$profiles = $this->getProfiles();
			$nm       = 1;
			
			$text .= PHP_EOL;
			$text .= 'Events:' . PHP_EOL;
			
			foreach ($profiles as $profile) {
				$text .= $nm ++ . '. ';
				$text .= $profile->getMessage() . ':';
				$text .= ' ' . round($profile->getElapsedTime(), 4) . 's';
				$text .= ' ' . $profile->getUsedMemory() . 'b';
				$text .= PHP_EOL;
			}
		}
		
		return $text;
	}