/*
 * See LICENSE file in distribution for copyright and licensing information.
 */
package org.yaml.snakeyaml;

import java.io.IOException;

import junit.framework.TestCase;

import org.yaml.snakeyaml.constructor.Constructor;

public class StressTest extends TestCase {
    String doc;

    public StressTest() throws IOException {
        doc = Util.getLocalResource("specification/example2_27.yaml");
    }

    public void testPerfomance() throws IOException {
        Loader loader = new Loader(new Constructor(Invoice.class));
        Yaml yaml = new Yaml(loader);
        int[] range = new int[] { 500, 1000 };
        float summ = 0;
        for (int number : range) {
            long time1 = System.currentTimeMillis();
            for (int i = 0; i < number; i++) {
                Invoice invoice = (Invoice) yaml.load(doc);
                assertNotNull(invoice);
            }
            long time2 = System.currentTimeMillis();
            float duration = (time2 - time1) / (float) number;
            summ += duration;
            System.out.println("Duration for r=" + number + " was " + duration + " ms/load.");
            assertTrue("duration=" + duration, duration < 5);
        }
    }
}

@@ -452,16 +452,27 @@
 rfomance
+OneInstance
 () throw
@@ -480,32 +480,32 @@
  IOException %7B%0D%0A
-
         Loader l
@@ -639,16 +639,22 @@
 00, 1000
+, 2000
  %7D;%0D%0A   
@@ -662,22 +662,43 @@
     
-float summ = 0
+System.out.println(%22One instance.%22)
 ;%0D%0A 
@@ -854,90 +854,21 @@
     
-Invoice invoice = (Invoice) yaml.load(doc);%0D%0A                assertNotNull(invoice
+yaml.load(doc
 );%0D%0A
@@ -1016,24 +1016,770 @@
     
-summ += duration
+System.out.println(%22Duration for r=%22 + number + %22 was %22 + duration + %22 ms/load.%22);%0D%0A            assertTrue(%22duration=%22 + duration, duration %3C 5);%0D%0A        %7D%0D%0A    %7D%0D%0A%0D%0A    public void testPerfomanceManyInstances() throws IOException %7B%0D%0A        int%5B%5D range = new int%5B%5D %7B 500, 1000, 2000 %7D;%0D%0A        System.out.println(%22Many instances.%22);%0D%0A        for (int number : range) %7B%0D%0A            long time1 = System.currentTimeMillis();%0D%0A            for (int i = 0; i %3C number; i++) %7B%0D%0A                Loader loader = new Loader(new Constructor(Invoice.class));%0D%0A                Yaml yaml = new Yaml(loader);%0D%0A                yaml.load(doc);%0D%0A            %7D%0D%0A            long time2 = System.currentTimeMillis();%0D%0A            float duration = (time2 - time1) / (float) number
 ;%0D%0A 

add a test for many instances