/*
 * 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.Date;

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;
        } else {
            if (allocationTime.before(startAllocationTime))
                startAllocationTime = allocationTime;
            if (allocationTime.after(endAllocationTime))
                endAllocationTime = 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;
    }
}

@@ -1938,24 +1938,33 @@
       return
+ (double)
  totalSize /
@@ -1972,32 +1972,32 @@
 numAllocations;%0A
-
     %7D%0A    %0A    p
@@ -2041,24 +2041,33 @@
       return
+ (double)
  totalBucket
@@ -2133,32 +2133,32 @@
 UsedBuckets() %7B%0A
-
         return t
@@ -2155,16 +2155,25 @@
   return
+ (double)
  totalUs

use floating pt division