// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class TestStd extends Test {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        long t1 = System.currentTimeMillis();
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("C:\\serstd.dat"));
        for(int i = 0; i < N; i++) {
            SomeData o = new SomeData(IV + i, XV, SV);
            oos.writeObject(o);
            if(i % 100 == 0) {
                oos.reset();
            }
        }
        oos.close();
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("C:\\serstd.dat"));
        for(int i = 0; i < N; i++) {
            SomeData o2 = (SomeData)ois.readObject();
            if((o2.getIv() != IV + i) || (o2.getXv() != XV) || !o2.getSv().equals(SV)) {
                throw new RuntimeException("Data corruption");
            }
        }
        ois.close();
        long t2 = System.currentTimeMillis();
        System.out.println(t2 - t1);
    }
}
