Example usage for java.lang System nanoTime

List of usage examples for java.lang System nanoTime

Introduction

In this page you can find the example usage for java.lang System nanoTime.

Prototype

@HotSpotIntrinsicCandidate
public static native long nanoTime();

Source Link

Document

Returns the current value of the running Java Virtual Machine's high-resolution time source, in nanoseconds.

Usage

From source file:math.test.TestDimpleRandom.java

/**
 * Measures speed of Apache vs Colt generators
 */// w w w.j  ava2s.c om
public static void main(String[] args) {
    RandomGenerator apacheGenerator = new MersenneTwister(42);
    cern.jet.random.engine.RandomEngine cernGenerator = new cern.jet.random.engine.MersenneTwister();

    final int N = 100000;
    long start, end;

    start = System.nanoTime();
    for (int i = N; --i >= 0;) {
        apacheGenerator.nextDouble();
    }
    end = System.nanoTime();
    long apacheTime = end - start;

    start = System.nanoTime();
    for (int i = N; --i >= 0;) {
        cernGenerator.nextDouble();
    }
    end = System.nanoTime();

    long cernTime = end - start;

    System.out.format("MersenneTwister.nextDouble() x %d apache/cern %f\n", N, (double) apacheTime / cernTime);

    start = System.nanoTime();
    for (int i = N; --i >= 0;) {
        BetaDistribution apacheBeta = new BetaDistribution(apacheGenerator, 1.0, 1.0);
        apacheBeta.sample();
    }
    end = System.nanoTime();
    apacheTime = end - start;

    cern.jet.random.Beta cernBeta = new cern.jet.random.Beta(1, 1, cernGenerator);

    start = System.nanoTime();
    for (int i = N; --i >= 0;) {
        cernBeta.nextDouble();
    }
    end = System.nanoTime();
    apacheTime = end - start;

    System.out.format("Beta x %d apache/cern %f\n", N, (double) apacheTime / cernTime);

    start = System.nanoTime();
    for (int i = N; --i >= 0;) {
        GammaDistribution apacheGamma = new GammaDistribution(apacheGenerator, 1.0, 1.0);
        apacheGamma.sample();
    }
    end = System.nanoTime();
    apacheTime = end - start;

    cern.jet.random.Gamma cernGamma = new cern.jet.random.Gamma(1, 1, cernGenerator);

    start = System.nanoTime();
    for (int i = N; --i >= 0;) {
        cernGamma.nextDouble();
    }
    end = System.nanoTime();
    apacheTime = end - start;

    System.out.format("Gamma x %d apache/cern %f\n", N, (double) apacheTime / cernTime);

    start = System.nanoTime();
    for (int i = N; --i >= 0;) {
        BinomialDistribution apacheBinomial = new BinomialDistribution(apacheGenerator, 1, .5);
        apacheBinomial.sample();
    }
    end = System.nanoTime();
    apacheTime = end - start;

    cern.jet.random.Binomial cernBinomial = new cern.jet.random.Binomial(1, .5, cernGenerator);

    start = System.nanoTime();
    for (int i = N; --i >= 0;) {
        cernBinomial.nextInt();
    }
    end = System.nanoTime();
    apacheTime = end - start;

    System.out.format("Binomial x %d apache/cern %f\n", N, (double) apacheTime / cernTime);
}

From source file:io.anserini.util.SearchTimeUtil.java

public static void main(String[] args) throws IOException, ParseException, ClassNotFoundException,
        NoSuchMethodException, InvocationTargetException, IllegalAccessException, InstantiationException {

    if (args.length != 1) {
        System.err.println("Usage: SearchTimeUtil <indexDir>");
        System.err.println("indexDir: index directory");
        System.exit(1);// w  ww. j  a  v  a  2s . co  m
    }

    String[] topics = { "topics.web.1-50.txt", "topics.web.51-100.txt", "topics.web.101-150.txt",
            "topics.web.151-200.txt", "topics.web.201-250.txt", "topics.web.251-300.txt" };

    SearchWebCollection searcher = new SearchWebCollection(args[0]);

    for (String topicFile : topics) {
        Path topicsFile = Paths.get("src/resources/topics-and-qrels/", topicFile);
        TopicReader tr = (TopicReader) Class.forName("io.anserini.search.query." + "Webxml" + "TopicReader")
                .getConstructor(Path.class).newInstance(topicsFile);
        SortedMap<Integer, String> queries = tr.read();
        for (int i = 1; i <= 3; i++) {
            final long start = System.nanoTime();
            String submissionFile = File.createTempFile(topicFile + "_" + i, ".tmp").getAbsolutePath();
            RerankerCascade cascade = new RerankerCascade();
            cascade.add(new IdentityReranker());
            searcher.search(queries, submissionFile, new BM25Similarity(0.9f, 0.4f), 1000, cascade);
            final long durationMillis = TimeUnit.MILLISECONDS.convert(System.nanoTime() - start,
                    TimeUnit.NANOSECONDS);
            System.out.println(topicFile + "_" + i + " search completed in "
                    + DurationFormatUtils.formatDuration(durationMillis, "mm:ss:SSS"));
        }
    }

    searcher.close();
}

From source file:Pong.java

public static void main(String... args) throws Exception {
    System.setProperty("os.max.pid.bits", "16");

    Options options = new Options();
    options.addOption("i", true, "Input chronicle path");
    options.addOption("n", true, "Number of entries to write");
    options.addOption("w", true, "Number of writer threads");
    options.addOption("r", true, "Number of reader threads");
    options.addOption("x", false, "Delete the output chronicle at startup");

    CommandLine cmd = new DefaultParser().parse(options, args);
    final Path output = Paths.get(cmd.getOptionValue("o", "/tmp/__test/chr"));
    final long maxCount = Long.parseLong(cmd.getOptionValue("n", "10000000"));
    final int writerThreadCount = Integer.parseInt(cmd.getOptionValue("w", "4"));
    final int readerThreadCount = Integer.parseInt(cmd.getOptionValue("r", "4"));
    final boolean deleteOnStartup = cmd.hasOption("x");

    if (deleteOnStartup) {
        FileUtil.removeRecursive(output);
    }/*ww  w . j a va2  s. c  o m*/

    final Chronicle chr = ChronicleQueueBuilder.vanilla(output.toFile()).build();

    final ExecutorService executor = Executors.newFixedThreadPool(4);
    final List<Future<?>> futures = new ArrayList<>();

    final long totalCount = writerThreadCount * maxCount;
    final long t0 = System.nanoTime();

    for (int i = 0; i != readerThreadCount; ++i) {
        final int tid = i;
        futures.add(executor.submit((Runnable) () -> {
            try {
                IntLongMap counts = HashIntLongMaps.newMutableMap();
                ExcerptTailer tailer = chr.createTailer();

                final StringBuilder sb1 = new StringBuilder();
                final StringBuilder sb2 = new StringBuilder();

                long count = 0;
                while (count != totalCount) {
                    if (!tailer.nextIndex())
                        continue;
                    final int id = tailer.readInt();
                    final long val = tailer.readStopBit();
                    final long longValue = tailer.readLong();
                    sb1.setLength(0);
                    sb2.setLength(0);
                    tailer.read8bitText(sb1);
                    tailer.read8bitText(sb2);
                    if (counts.addValue(id, 1) - 1 != val || longValue != 0x0badcafedeadbeefL
                            || !StringInterner.isEqual("FooBar", sb1)
                            || !StringInterner.isEqual("AnotherFooBar", sb2)) {
                        System.out.println("Unexpected value " + id + ", " + val + ", "
                                + Long.toHexString(longValue) + ", " + sb1.toString() + ", " + sb2.toString());
                        return;
                    }
                    ++count;
                    if (count % 1_000_000 == 0) {
                        long t1 = System.nanoTime();
                        System.out.println(tid + " " + (t1 - t0) / 1e6 + " ms");
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }));
    }
    for (Future f : futures) {
        f.get();
    }
    executor.shutdownNow();

    final long t1 = System.nanoTime();
    System.out.println("Done. Rough time=" + (t1 - t0) / 1e6 + " ms");
}

From source file:ca.uqac.info.trace.TraceGenerator.java

public static void main(String[] args) {
    // Parse command line arguments
    Options options = setupOptions();//w w  w  . j a  va  2s.  c o  m
    CommandLine c_line = setupCommandLine(args, options);
    int verbosity = 0, max_events = 1000000;

    if (c_line.hasOption("h")) {
        showUsage(options);
        System.exit(ERR_OK);
    }
    String generator_name = "simplerandom";
    if (c_line.hasOption("g")) {
        generator_name = c_line.getOptionValue("generator");
    }
    long time_per_msg = 1000;
    if (c_line.hasOption("i")) {
        time_per_msg = Integer.parseInt(c_line.getOptionValue("i"));
    }
    if (c_line.hasOption("verbosity")) {
        verbosity = Integer.parseInt(c_line.getOptionValue("verbosity"));
    }
    if (c_line.hasOption("e")) {
        max_events = Integer.parseInt(c_line.getOptionValue("e"));
    }
    String feeder_params = "";
    if (c_line.hasOption("parameters")) {
        feeder_params = c_line.getOptionValue("parameters");
    }
    MessageFeeder mf = instantiateFeeder(generator_name, feeder_params);
    if (mf == null) {
        System.err.println("Unrecognized feeder name");
        System.exit(ERR_ARGUMENTS);
    }
    // Trap Ctrl-C to send EOT before shutting down
    Runtime.getRuntime().addShutdownHook(new Thread() {
        public void run() {
            char EOT = 4;
            System.out.print(EOT);
        }
    });
    for (int num_events = 0; mf.hasNext() && num_events < max_events; num_events++) {
        long time_begin = System.nanoTime();
        String message = mf.next();
        StringBuilder out = new StringBuilder();
        out.append(message);
        System.out.print(out.toString());
        long time_end = System.nanoTime();
        long duration = time_per_msg - (long) ((time_end - time_begin) / 1000000f);
        if (duration > 0) {
            try {
                Thread.sleep(duration);
            } catch (InterruptedException e) {
            }
        }
        if (verbosity > 0) {
            System.err.print("\r" + num_events + " " + duration + "/" + time_per_msg);
        }
    }
}

From source file:com.quest.orahive.HiveJdbcClient.java

public static void main(String[] args) {

    long mainStartTime = System.nanoTime();

    Configuration conf = new Configuration();
    Options options = new Options();

    parseGeneralOptions(options, conf, args); //<- log4j will now be configured.

    showWelcomeMessage();//from  ww  w .  j  av a  2 s  . com

    if (args.length == 0 || userWantsToSeeHelp(args)) {
        printCommandLineHelp(options);
        System.exit(0);
    }

    checkConfiguration(conf);

    OraHiveOptions opts = getOraHiveOptions(conf);
    OraHiveCounters counters = new OraHiveCounters();

    try {
        Connection hiveConnection = createHiveJdbcConnection(opts.hiveJdbcUrl, opts.hiveUserName,
                opts.hivePassword);
        try {
            Connection oracleConnection = createOracleJdbcConnection(opts.oracleJdbcUrl, opts.oracleUserName,
                    opts.oraclePassword);
            try {
                initializeOracleSession(oracleConnection, opts);

                Statement statement = hiveConnection.createStatement();

                LOG.info("Running: " + opts.hql);

                // Execute Hive Query...
                long start = System.nanoTime();
                ResultSet hiveResultSet = statement.executeQuery(opts.hql);
                counters.hiveQueryTimeNanoSec = System.nanoTime() - start;

                // Get column definitions from the Hive resultset...
                List<OracleTableColumn> oracleColumns = getOracleTableColumnsForHiveResults(hiveResultSet);

                if (opts.exportMode.equals(Constants.ExportMode.CREATE)) {
                    // Create an Oracle table based on the columns in the Hive resultset...
                    createOracleTableWithRetry(opts, oracleColumns, oracleConnection); //<- Lets the user retry this if it fails.
                }

                // Generate the Oracle insert statement...
                String insertSql = generateOracleInsertStatement(opts, oracleColumns);

                // Insert the Hive data into Oracle...
                insertHiveResultsIntoOracleTable(opts, insertSql, oracleColumns, oracleConnection,
                        hiveResultSet, counters);

                //hiveResultSet.close();   //<- Not required/supported
                statement.close();
            } finally {
                oracleConnection.close();
            }
        } finally {
            hiveConnection.close();
        }

    } catch (SQLException ex) {
        LOG.error(String.format("An error occurred in %s.", Constants.ORAHIVE_PRODUCT_NAME), ex);
    }

    LOG.info(String.format("\n\n********************************************************************\n"
            + "\tTotal time                        : %s sec.\n" + "\tNumber of records processed       : %s\n"
            + "\tTime spent executing HQL statement: %s sec.\n"
            + "\tTime spent fetching Hive data     : %s sec.\n"
            + "\tTime spent inserting into Oracle  : %s sec.",
            (System.nanoTime() - mainStartTime) / Math.pow(10, 9), counters.rowsProcessed,
            counters.hiveQueryTimeNanoSec / Math.pow(10, 9), counters.hiveFetchTimeNanoSec / Math.pow(10, 9),
            counters.oracleInsertTimeNanoSec / Math.pow(10, 9)));

}

From source file:com.adeptj.runtime.core.Launcher.java

/**
 * Entry point for initializing the AdeptJ Runtime.
 * <p>// w  ww  .j a  v a2  s  .  co  m
 * It does the following tasks in order.
 * <p>
 * 1. Initializes the Logback logging framework.
 * 2. Does the deployment to embedded UNDERTOW.
 * 3. Starts the OSGi Framework.
 * 4. Starts the Undertow server.
 * 5. Registers the runtime ShutdownHook.
 *
 * @param args command line arguments for the Launcher.
 */
public static void main(String[] args) {
    Thread.currentThread().setName("AdeptJ Launcher");
    long startTime = System.nanoTime();
    LogbackInitializer.init();
    Logger logger = LoggerFactory.getLogger(Launcher.class);
    try {
        pauseForDebug();
        logger.info("JRE: [{}], Version: [{}]", JAVA_RUNTIME_NAME, JAVA_RUNTIME_VERSION);
        Map<String, String> runtimeArgs = parseArgs(args);
        Lifecycle lifecycle = new Server(runtimeArgs);
        lifecycle.start();
        Runtime.getRuntime().addShutdownHook(new ShutdownHook(lifecycle, Constants.SERVER_STOP_THREAD_NAME));
        launchBrowser(runtimeArgs);
        logger.info("AdeptJ Runtime initialized in [{}] ms!!", Times.elapsedMillis(startTime));
    } catch (Throwable th) { // NOSONAR
        logger.error("Exception while initializing AdeptJ Runtime!!", th);
        shutdownJvm();
    }
}

From source file:data_gen.Data_gen.java

public static void main(String[] args) throws FileNotFoundException, IOException {
    long startTime = System.nanoTime();
    if (args.length < 2) {
        System.out.println("Usage:");
        System.out.println(/*from w w  w  .j  av a2s.com*/
                "java -jar \"jarfile\" [Directory of text source folder] [Dierctory of configration file]"
                        + "\n");
        System.exit(0);
    }

    String Dir = args[0]; // get text source dir from user
    String config_dir = args[1];
    File folder = new File(Dir);
    if (folder.isDirectory() == false) {
        System.out.println("Text souce folder is not a Directory." + "\n");
        System.exit(0);
    }
    if (!config_dir.endsWith(".properties") && !config_dir.endsWith(".PROPERTIES")) {
        System.out.println("\n"
                + "There was error parsing dataset parameters from configuration file, make sure you have the 4 parameters specified and the right type of file"
                + "\n");
        System.exit(0);
    }

    listOfFiles = folder.listFiles(new FilenameFilter() {
        @Override
        public boolean accept(File dir, String name) {
            return name.toLowerCase().endsWith(".txt");
        }
    });

    if (listOfFiles.length == 0) {
        System.out.println("Text source folder is empty ! Have at least one .txt file there" + "\n");
        System.exit(0);
    }

    System.out.println("\n");
    Parse_Document_values(config_dir);// parse config file to get class attribute values
    document_size = Docments_Total_size / documents_count; // to get each document size 
    max = (long) ((double) document_size * 1.8);
    min = (long) ((double) document_size * 0.2);

    schema_fields = Parse_Document_fields(config_dir);

    try {
        LineIterator it = FileUtils.lineIterator(listOfFiles[0]);

        while (it.hasNext()) {
            tx.add(it.nextLine());
        }
    } catch (NullPointerException | FileNotFoundException e) {
        System.out.println("The text source file could not be found." + "\n");
        System.exit(0);
    }

    new File(output_dir).mkdir();
    //////////////////////////////////////////////////////////////// build json or .dat
    ////////////////////////////////////////////////////////////////////     
    if (Default_DataSet_name.endsWith(".json")) {
        Build_json_file(config_dir, startTime);
    }

    if (Default_DataSet_name.endsWith(".dat")) {
        Build_dat_file(config_dir, startTime);
    }

    generate_xml();
    generate_field_map();

}

From source file:languageTools.Analyzer.java

/**
 *
 * @param args//from   w w  w  . jav  a  2s  .  c  om
 * @throws Exception
 */
public static void main(String[] args) {

    // Get start time.
    long startTime = System.nanoTime();

    // Parse command line options
    File file;
    try {
        file = parseOptions(args);
    } catch (ParseException e) {
        System.out.println(e.getMessage());
        showHelp();
        return;
    }

    // Get all files that should be analyzed
    List<File> files = new ArrayList<File>();
    if (file.isDirectory()) {
        // Search directory for indicated file types
        files = searchDirectory(file);
        System.out.println("Found " + files.size() + " file(s).\n");
    } else {
        files.add(file);
    }

    // Process files found
    for (File filefound : files) {
        System.out.println("Processing file: " + filefound.getPath() + ".\n");
        Validator<?, ?, ?, ?> validator = null;
        switch (Extension.getFileExtension(filefound)) {
        case GOAL:
            validator = new AgentValidator(filefound.getPath());
            // TODO we need to set a KR interface; use default (only one)
            // right now. Best we can do now
            // is to ask user to set it.
            try {
                ((AgentValidator) validator).setKRInterface(KRFactory.getDefaultInterface());
            } catch (KRInitFailedException e) {
                // TODO: use logger.
                System.out.println(e.getMessage());
            }
            break;
        case MOD2G:
            validator = new ModuleValidator(filefound.getPath());
            // TODO we need to set a KR interface; use default (only one)
            // right now. Best we can do now
            // is to ask user to set it.
            try {
                ((ModuleValidator) validator).setKRInterface(KRFactory.getDefaultInterface());
            } catch (KRInitFailedException e) {
                // TODO: use logger.
                System.out.println(e.getMessage());
            }
            break;
        case MAS2G:
            validator = new MASValidator(filefound.getPath());
            break;
        case TEST2G:
            validator = new TestValidator(filefound.getPath());
            break;
        default:
            // TODO: use logger.
            System.out.println("Expected file with extension 'goal', 'mas2g', 'mod2g', or 'test2g'");
            continue;
        }

        // Validate program file
        validator.validate();

        // Print lexer tokens
        if (lexer) {
            validator.printLexerTokens();
        }

        // Print constructed program
        if (program) {
            System.out.println("\n\n" + validator.getProgram().toString(" ", " "));
        }

        // Print report with warnings, and parsing and validation messages
        System.out.println(validator.report());
    }

    // Get elapsed time.
    long elapsedTime = (System.nanoTime() - startTime) / 1000000;
    System.out.println("Took " + elapsedTime + " milliseconds to analyze " + files.size() + " file(s).");
}

From source file:io.adeptj.runtime.core.Launcher.java

/**
 * Entry point for initializing the AdeptJ Runtime.
 * <p>//from  w w  w . jav a  2  s. co m
 * It does the following tasks in order.
 * <p>
 * 1. Initializes the Logback logging framework.
 * 2. Does the deployment to embedded UNDERTOW.
 * 3. Starts the OSGi Framework.
 * 4. Starts the Undertow server.
 * 5. Registers the runtime ShutdownHook.
 *
 * @param args command line arguments for the Launcher.
 */
public static void main(String[] args) {
    Thread.currentThread().setName("AdeptJ Launcher");
    long startTime = System.nanoTime();
    LogbackInitializer.init();
    Logger logger = LoggerFactory.getLogger(Launcher.class);
    try {
        pauseForDebug();
        logger.info("JRE: [{}], Version: [{}]", JAVA_RUNTIME_NAME, JAVA_RUNTIME_VERSION);
        Map<String, String> commands = parseArgs(args);
        Lifecycle lifecycle = new Server();
        lifecycle.start();
        Runtime.getRuntime().addShutdownHook(new ShutdownHook(lifecycle, SERVER_STOP_THREAD_NAME));
        launchBrowser(commands);
        logger.info("AdeptJ Runtime initialized in [{}] ms!!", Times.elapsedMillis(startTime));
    } catch (Throwable th) { // NOSONAR
        logger.error("Exception while initializing AdeptJ Runtime!!", th);
        shutdownJvm(th);
    }
}

From source file:lambertmrev.LambertMRev.java

/**
 * @param args the command line arguments
 *///from  w  w w .jav  a2s.  c om
public static void main(String[] args) {
    // Want to test the Lambert class so you can specify the number of revs for which to compute
    //System.out.print("this is the frames tutorial \n");
    try {
        Frame inertialFrame = FramesFactory.getEME2000();
        TimeScale utc = TimeScalesFactory.getTAI();
        AbsoluteDate initialDate = new AbsoluteDate(2004, 01, 01, 23, 30, 00.000, utc);
        double mu = 3.986004415e+14;

        double a = 24396159; // semi major axis in meters
        double e = 0.72831215; // eccentricity
        double i = Math.toRadians(7); // inclination
        double omega = Math.toRadians(180); // perigee argument
        double raan = Math.toRadians(261); // right ascension of ascending node
        double lM = 0; // mean anomaly

        Orbit initialOrbit = new KeplerianOrbit(a, e, i, omega, raan, lM, PositionAngle.MEAN, inertialFrame,
                initialDate, mu);
        //KeplerianPropagator kepler = new KeplerianPropagator(initialOrbit);

        // set geocentric positions
        Vector3D r1 = new Vector3D(-6.88999e3, 3.92763e4, 2.67053e3);
        Vector3D r2 = new Vector3D(-3.41458e4, 2.05328e4, 3.44315e3);
        Vector3D r1_site = new Vector3D(4.72599e3, 1.26633e3, 4.07799e3);
        Vector3D r2_site = new Vector3D(4.70819e3, 1.33099e3, 4.07799e3);

        // get the topocentric positions
        Vector3D top1 = Transform.geo2radec(r1.scalarMultiply(1000), r1_site.scalarMultiply(1000));
        Vector3D top2 = Transform.geo2radec(r2.scalarMultiply(1000), r2_site.scalarMultiply(1000));

        // time of flight in seconds
        double tof = 3 * 3600;

        // propagate to 0 and tof
        Lambert test = new Lambert();

        boolean cw = false;
        int multi_revs = 1;
        RealMatrix v1_mat;
        Random randomGenerator = new Random();

        PrintWriter out_a = new PrintWriter("out_java_a.txt");
        PrintWriter out_e = new PrintWriter("out_java_e.txt");
        PrintWriter out_rho1 = new PrintWriter("out_java_rho1.txt");
        PrintWriter out_rho2 = new PrintWriter("out_java_rho2.txt");

        // start the loop
        double A, Ecc, rho1, rho2, tof_hyp;

        long time1 = System.nanoTime();
        for (int ll = 0; ll < 1e6; ll++) {

            rho1 = top1.getZ() / 1000 + 1e-3 * randomGenerator.nextGaussian() * top1.getZ() / 1000;
            rho2 = top2.getZ() / 1000 + 1e-3 * randomGenerator.nextGaussian() * top2.getZ() / 1000;
            //tof_hyp = FastMath.abs(tof + 0.1*3600 * randomGenerator.nextGaussian());
            // from topo to geo
            Vector3D r1_hyp = Transform.radec2geo(top1.getX(), top1.getY(), rho1, r1_site);
            Vector3D r2_hyp = Transform.radec2geo(top2.getX(), top2.getY(), rho2, r2_site);
            //            System.out.println(r1_hyp.scalarMultiply(1000).getNorm());
            //            System.out.println(r2_hyp.scalarMultiply(1000).getNorm());
            //            System.out.println(tof/3600);
            test.lambert_problem(r1_hyp.scalarMultiply(1000), r2_hyp.scalarMultiply(1000), tof, mu, cw,
                    multi_revs);

            v1_mat = test.get_v1();

            Vector3D v1 = new Vector3D(v1_mat.getEntry(0, 0), v1_mat.getEntry(0, 1), v1_mat.getEntry(0, 2));
            //            System.out.println(v1);
            PVCoordinates rv1 = new PVCoordinates(r1_hyp.scalarMultiply(1000), v1);
            Orbit orbit_out = new KeplerianOrbit(rv1, inertialFrame, initialDate, mu);
            A = orbit_out.getA();
            Ecc = orbit_out.getE();

            //            System.out.println(ll + " - " +A);
            out_a.println(A);
            out_e.println(Ecc);
            out_rho1.println(rho1);
            out_rho2.println(rho2);
        }
        long time2 = System.nanoTime();
        long timeTaken = time2 - time1;

        out_a.close();
        out_e.close();
        out_rho1.close();
        out_rho2.close();

        System.out.println("Time taken " + timeTaken / 1000 / 1000 + " milli secs");

        // get the truth
        test.lambert_problem(r1.scalarMultiply(1000), r2.scalarMultiply(1000), tof, mu, cw, multi_revs);
        v1_mat = test.get_v1();
        Vector3D v1 = new Vector3D(v1_mat.getEntry(0, 0), v1_mat.getEntry(0, 1), v1_mat.getEntry(0, 2));
        PVCoordinates rv1 = new PVCoordinates(r1.scalarMultiply(1000), v1);
        Orbit orbit_out = new KeplerianOrbit(rv1, inertialFrame, initialDate, mu);
        //System.out.println(orbit_out.getA());
    } catch (FileNotFoundException ex) {
        Logger.getLogger(LambertMRev.class.getName()).log(Level.SEVERE, null, ex);
    }
}