// Copyright 2000-2003, FreeHEP.
package hep.graphics.heprep.test;

import java.awt.Color;
import java.io.IOException;
import java.io.FileWriter;
import java.util.Stack;

import hep.graphics.heprep.*;
import hep.graphics.heprep.xml.*;
import hep.graphics.heprep.util.*;

/**
 *
 * @author M.Donszelmann
 *
 * @version $Id: CopyTest.java,v 1.5 2003/12/02 23:50:05 duns Exp $
 */

public class CopyTest {
    public static final String cvsId = "$Id: CopyTest.java,v 1.5 2003/12/02 23:50:05 duns Exp $";

    public void run(String iname, String oname) throws Exception {
        long t0, t1, t2, t3, t4, t5;
        t0 = System.currentTimeMillis();

        HepRep heprep = HepRepIO.readHepRep(iname);
        t1 = System.currentTimeMillis();
        System.out.println("Read file in "+(t1-t0)+" ms.");

        HepRep copy = heprep.copy();
        t2 = System.currentTimeMillis();
        System.out.println("Copied heprep in "+(t2-t1)+" ms.");
        
        if (copy.equals(heprep)) {
            System.out.println("Copy is equal to Original");
        } else {
            System.out.println("Copy is DIFFERENT than Original");
        }
        t3 = System.currentTimeMillis();
        System.out.println("Comparing files used "+(t3-t2)+" ms.");

        HepRepIO.writeHepRep(heprep, "orig."+oname);
        t4 = System.currentTimeMillis();
        System.out.println("Written orig file in "+(t4-t3)+" ms.");

        HepRepIO.writeHepRep(copy, oname);
        t5 = System.currentTimeMillis();
        System.out.println("Written file in "+(t5-t4)+" ms.");
    }

    public static void main(String[] args) {
        if (args.length != 2) {
            System.out.println("Usage: CopyTest inputfilename outputfilename");
            System.exit(1);
        }

        try {
            new CopyTest().run(args[0], args[1]);
        } catch (Exception e) {
	        System.out.println(e);
	        e.printStackTrace();
        }
    }


}
