001 package jp.osdl.jbento2.analyzer; 002 003 import java.util.Iterator; 004 005 public class RampUpDurationFilter { 006 007 private long rampUpMillis = 0; 008 009 private long durationMillis = 0; 010 011 public RampUpDurationFilter(long rampUpMillis, long durationMillis) { 012 this.rampUpMillis = rampUpMillis; 013 this.durationMillis = durationMillis; 014 } 015 016 public SampleList doFilter(SampleList src) { 017 if (src.isEmpty() || (rampUpMillis == 0 && durationMillis == 0)) { 018 return src; 019 } 020 021 SampleList result = new SampleList(); 022 long first = Long.MAX_VALUE; 023 for (Iterator it = src.iterator(); it.hasNext();) { 024 Sample s = (Sample) it.next(); 025 if (first > s.getStartTime().getMillitime()) { 026 first = s.getStartTime().getMillitime(); 027 } 028 } 029 030 long start = first + rampUpMillis; 031 long end = start + durationMillis; 032 033 for (Iterator it = src.iterator(); it.hasNext();) { 034 Sample s = (Sample) it.next(); 035 if (start <= s.getStartTime().getMillitime() 036 && end >= s.getEndTime().getMillitime()) { 037 result.add(s); 038 } 039 } 040 041 return result; 042 } 043 }