/*
 * hashshmash - An aspect to record HashMap/Set allocations
 * Copyright 2013 MeBigFatGuy.com
 * Copyright 2013 Dave Brosius
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and limitations
 * under the License.
 */
package com.mebigfatguy.hashshmash;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class SiteAllocationInfo {

    private Date startAllocationTime;
    private Date endAllocationTime;
    private int numAllocations;
    private int totalSize;
    private int totalBuckets;
    private int totalUsedBuckets;
    
    public void add(Date allocationTime, int size, int buckets, int usedBuckets) {
        if (startAllocationTime == null)
            startAllocationTime = allocationTime;
        endAllocationTime = allocationTime;
        ++numAllocations;
        totalSize += size;
        totalBuckets += buckets;
        totalUsedBuckets += usedBuckets;
    }
    
    public Date getStartAllocationTime() {
        return startAllocationTime;
    }
    
    public Date getEndAllocationTime() {
        return endAllocationTime;
    }
    
    public int getNumAllocations() {
        return numAllocations;
    }
    
    public double getAverageSize() {
        return totalSize / numAllocations;
    }
    
    public double getAverageBuckets() {
        return totalBuckets / numAllocations;
    }
    
    public double getAverageUsedBuckets() {
        return totalUsedBuckets / numAllocations;
    }
}

@@ -1154,16 +1154,18 @@
 == null)
+ %7B
 %0A       
@@ -1199,32 +1199,330 @@
 allocationTime;%0A
+            endAllocationTime = allocationTime;%0A        %7D else %7B%0A            if (allocationTime.before(startAllocationTime))%0A                startAllocationTime = allocationTime;%0A            if (allocationTime.after(endAllocationTime))%0A                endAllocationTime = allocationTime;%0A        %7D%0A
         endAlloc

fix start/end calc