| package org.eclipse.app4mc.amalthea._import.btf.model; |
| |
| import java.util.List; |
| import java.util.stream.Collectors; |
| import java.util.stream.Stream; |
| |
| import org.eclipse.app4mc.amalthea.model.ProcessEventType; |
| import org.eclipse.app4mc.amalthea.model.RunnableEventType; |
| import org.eclipse.emf.common.util.Enumerator; |
| |
| public enum BTFCountMetric { |
| |
| activations(ProcessEventType.ACTIVATE), |
| preemptions(ProcessEventType.PREEMPT), |
| suspensions(RunnableEventType.SUSPEND); |
| |
| public final Enumerator eventToCount; |
| public final BTFEntityType entityType; |
| |
| private BTFCountMetric(final Enumerator eventToCount) { |
| this.eventToCount = eventToCount; |
| String entityTypeName = eventToCount.getClass().getSimpleName(); |
| entityTypeName = entityTypeName.substring(0, entityTypeName.indexOf("EventType")).toLowerCase(); |
| this.entityType = BTFEntityType.getForName(entityTypeName); |
| } |
| |
| public static List<Enumerator> getInvolvedBTFEventsForEntityType(final BTFEntityType entityType) { |
| return Stream.of(BTFCountMetric.values()).filter(cm -> cm.entityType == entityType) |
| .map(cm -> cm.eventToCount).collect(Collectors.toList()); |
| } |
| |
| } |