changeset 203:7c6a0ca567b3

SampleBuffer should zero on backoff.
author shade
date Mon, 14 Oct 2013 17:14:14 +0400
parents 01fe2ffe529a
children 04aa6b49fc0e
files jmh-core/src/main/java/org/openjdk/jmh/util/internal/SampleBuffer.java
diffstat 1 files changed, 7 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/util/internal/SampleBuffer.java	Mon Oct 14 16:47:30 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/util/internal/SampleBuffer.java	Mon Oct 14 17:14:14 2013 +0400
@@ -38,10 +38,8 @@
     private final int size;
     private int index;
 
-    private boolean full;
-
     public SampleBuffer() {
-        this(1000);
+        this(1024);
     }
 
     public SampleBuffer(int size) {
@@ -50,18 +48,18 @@
     }
 
     public boolean add(long sample) {
-        samples[index++] = sample;
-
-        if (index >= size) {
+        if (index == size) {
+            samples[0] = sample;
             index = 0;
-            full = true;
             return true;
+        } else {
+            samples[index++] = sample;
+            return false;
         }
-        return false;
     }
 
     public long[] getSamples() {
-        return full ? Arrays.copyOf(samples, size) : Arrays.copyOf(samples, index);
+        return Arrays.copyOf(samples, index);
     }
 
     public void addAll(long[] samples) {