Ignore:
Timestamp:
05/03/16 17:06:33 (9 years ago)
Author:
pharms
Message:
  • implemented some performance improvements
Location:
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/taskequality/GUIEventTaskComparisonRule.java

    r1887 r2126  
    4343import de.ugoe.cs.autoquest.eventcore.guimodel.IText; 
    4444import de.ugoe.cs.autoquest.eventcore.guimodel.IToolTip; 
     45import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 
    4546import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance; 
    4647import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 
     
    6869    @Override 
    6970    public boolean isApplicable(ITask task1, ITask task2) { 
    70         for (ITaskInstance instance : task1.getInstances()) { 
    71             if ((!(instance instanceof IEventTaskInstance)) || 
    72                 (!(((IEventTaskInstance) instance).getEvent().getType() instanceof IInteraction))) 
    73             { 
    74                 return false; 
    75             } 
    76         } 
    77          
    78         for (ITaskInstance instance : task2.getInstances()) { 
    79             if ((!(instance instanceof IEventTaskInstance)) || 
    80                 (!(((IEventTaskInstance) instance).getEvent().getType() instanceof IInteraction))) 
    81             { 
    82                 return false; 
    83             } 
     71        if (!(task1 instanceof IEventTask)) { 
     72            return false; 
     73        } 
     74         
     75        if (!(task2 instanceof IEventTask)) { 
     76            return false; 
     77        } 
     78         
     79        IEventTaskInstance instance1 = (IEventTaskInstance) task1.getInstances().iterator().next(); 
     80         
     81        if (!(instance1.getEvent().getType() instanceof IInteraction)) { 
     82            return false; 
     83        } 
     84         
     85        IEventTaskInstance instance2 = (IEventTaskInstance) task2.getInstances().iterator().next(); 
     86         
     87        if (!(instance2.getEvent().getType() instanceof IInteraction)) { 
     88            return false; 
    8489        } 
    8590         
     
    178183        Collection<ITaskInstance> taskInstances1 = task1.getInstances(); 
    179184        Collection<ITaskInstance> taskInstances2 = task2.getInstances(); 
     185         
     186        if (taskInstances1.size() > taskInstances2.size()) { 
     187            // it may be the case, that all instances of first task match already the first instance 
     188            // of the second task. In this case, the below for loops would iterate of all instances 
     189            // of the first task but the internal loop would always break. But if the first task 
     190            // has many more instances than the second task, performing the comparison the other 
     191            // way around would result in less comparisons. Hence, we switch the task instance lists 
     192            // to have fewer comparisons. 
     193            Collection<ITaskInstance> tmp = taskInstances1; 
     194            taskInstances1 = taskInstances2; 
     195            taskInstances2 = tmp; 
     196        } 
    180197         
    181198        TaskEquality checkedEquality = 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/utils/SimilarTasks.java

    r1980 r2126  
    13011301     */ 
    13021302    private boolean isInefficientAction(ITask task) { 
    1303         ITaskInstance inst = task.getInstances().iterator().next(); 
    1304          
    1305         if ((inst instanceof IEventTaskInstance) && 
    1306             (((IEventTaskInstance) inst).getEvent().getType() instanceof Scroll)) 
    1307         { 
    1308             return true; 
     1303        if (task instanceof IEventTask) { 
     1304            IEventTaskInstance inst = (IEventTaskInstance) task.getInstances().iterator().next(); 
     1305            if (inst.getEvent().getType() instanceof Scroll) { 
     1306                return true; 
     1307            } 
     1308            else { 
     1309                return false; 
     1310            } 
    13091311        } 
    13101312        else if (task instanceof IMarkingTemporalRelationship) { 
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/Task.java

    r1400 r2126  
    8181     * </p> 
    8282     */ 
    83     private Collection<ITaskInstance> instances = new HashSet<ITaskInstance>(); 
     83    private final Collection<ITaskInstance> instances = new HashSet<ITaskInstance>(); 
     84     
     85    /** 
     86     * <p> 
     87     * the unmodifiable view on the instances of this task 
     88     * </p> 
     89     */ 
     90    private final Collection<ITaskInstance> unmodifiableInstances; 
    8491     
    8592    /** 
     
    107114            throw new IllegalArgumentException("type must not be null"); 
    108115        } 
     116         
     117        unmodifiableInstances = Collections.unmodifiableCollection(instances); 
    109118    } 
    110119 
     
    154163    @Override 
    155164    public Collection<ITaskInstance> getInstances() { 
    156         return Collections.unmodifiableCollection(instances); 
     165        return unmodifiableInstances; 
    157166    } 
    158167 
Note: See TracChangeset for help on using the changeset viewer.