Example usage for java.lang System currentTimeMillis

List of usage examples for java.lang System currentTimeMillis

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static native long currentTimeMillis();

Source Link

Document

Returns the current time in milliseconds.

Usage

From source file:org.apache.cxf.transport.xmpp.pubsub.Client.java

public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext("client-pubsub-applicationContext.xml");
    HelloWorld client = (HelloWorld) context.getBean("helloClient");

    long startTime = System.currentTimeMillis();
    client.yell("One way message!!!");
    System.out.println("Elapsed time: " + (System.currentTimeMillis() - startTime));

    startTime = System.currentTimeMillis();
    client.yell("Second message!!");
    System.out.println("Elapsed time: " + (System.currentTimeMillis() - startTime));
}

From source file:SocialClientTest.java

public static void main(String[] args) throws InterruptedException {

    //   createSendSocialData();

    logger.info(System.currentTimeMillis() / 1000);

    startProxy();//from  w w w.  ja v  a  2  s  .c o  m
}

From source file:SetTest.java

public static void main(String[] args) {
    Set<String> words = new HashSet<String>(); // HashSet implements Set
    long totalTime = 0;

    Scanner in = new Scanner(System.in);
    while (in.hasNext()) {
        String word = in.next();/* ww w . ja  v a2  s .  co  m*/
        long callTime = System.currentTimeMillis();
        words.add(word);
        callTime = System.currentTimeMillis() - callTime;
        totalTime += callTime;
    }

    Iterator<String> iter = words.iterator();
    for (int i = 1; i <= 20 && iter.hasNext(); i++)
        System.out.println(iter.next());
    System.out.println(". . .");
    System.out.println(words.size() + " distinct words. " + totalTime + " milliseconds.");
}

From source file:Main.java

public static void main(String args[]) {
    millisecondToDHMS(System.currentTimeMillis());
}

From source file:ch.vorburger.mifos.wiki.ZWikiJRstConverter.java

public static void main(String[] args) throws Exception {
    ZWikiJRstConverter conv = new ZWikiJRstConverter();
    long startTime = System.currentTimeMillis();
    if (args.length == 1) {
        conv.convertPage(new File(args[0]));
    } else {/*from w  ww  .  j a v  a 2s  .  c o  m*/
        conv.convertPages(new File("target/wikiContent/"));
    }
    long endTime = System.currentTimeMillis();
    System.out.println("\n\nConversion skipped (not attempted) for the following input pages :");
    for (File skippedPageName : conv.skippedPageNames) {
        System.out.println(skippedPageName);
    }
    System.out.println(
            "\n\nConversion failed for the following input pages; an empty page with label 'tbd_mig_manual' will be uploaded instead (see above for detailed exceptions) :");
    for (File failedPageName : conv.failedPageNames) {
        System.out.println(failedPageName);
    }
    System.out.println(
            "\n\nConversion from reStructuredText to XML took " + ((endTime - startTime) / 1000) + "s");
    System.out.println("\n\nConverted " + conv.successfulPages + " sucessfully, but skipped "
            + conv.skippedPageNames.size() + " and failed " + conv.failedPages + " (total "
            + (conv.successfulPages + conv.failedPages + conv.skippedPageNames.size()) + ")");
}

From source file:JoinDemo.java

public static void main(String[] args) {
    Thread[] t = new Thread[3];

    t[0] = createThread("thread A", 2000);
    t[1] = createThread("thread B", 1000);
    t[2] = createThread("thread C", 3000);

    for (int i = 0; i < t.length; i++) {
        try {/* ww w . ja  va2 s. c o  m*/
            String idxStr = "thread[" + i + "]";
            String name = "[" + t[i].getName() + "]";

            print(idxStr + ".isAlive()=" + t[i].isAlive() + " " + name);
            print("about to do: " + idxStr + ".join() " + name);

            long start = System.currentTimeMillis();
            t[i].join(); // wait for the thread to die
            long stop = System.currentTimeMillis();

            print(idxStr + ".join() - took " + (stop - start) + " ms " + name);
        } catch (InterruptedException x) {
            print("interrupted waiting on #" + i);
        }
    }
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Main q = new Main();
    long start = System.currentTimeMillis();

    // Run the queues for 30 seconds, add CPU-light and CPU-weight tasks
    // every second.
    while (System.currentTimeMillis() - start <= 30 * 1000L) {
        q.runOrQueueHeavyTask(new SampleHeavyTask());
        q.runOrQueueLightTask(new SampleLightTask());
        Thread.sleep(1000L);/*from w ww . ja  v a 2 s.  c  o  m*/
    }

    q.shutDownNow();
}

From source file:com.genentech.struchk.sdfNormalizer.java

public static void main(String[] args) {
    long start = System.currentTimeMillis();
    int nMessages = 0;
    int nErrors = 0;
    int nStruct = 0;

    // create command line Options object
    Options options = new Options();
    Option opt = new Option("in", true, "input file [.ism,.sdf,...]");
    opt.setRequired(true);//from  w  w w  . java 2s . c  o  m
    options.addOption(opt);

    opt = new Option("out", true, "output file");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("mol", true, "molFile used for output: ORIGINAL(def)|NORMALIZED|TAUTOMERIC");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("shortMessage", false,
            "Limit message to first 80 characters to conform with sdf file specs.");
    opt.setRequired(false);
    options.addOption(opt);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd;
    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        exitWithHelp(options, e.getMessage());
        throw new Error(e); // avoid compiler errors
    }
    args = cmd.getArgs();

    if (args.length != 0) {
        System.err.print("Unknown options: " + args + "\n\n");
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("sdfNormalizer", options);
        System.exit(1);
    }

    String molOpt = cmd.getOptionValue("mol");
    OUTMolFormat outMol = OUTMolFormat.ORIGINAL;
    if (molOpt == null || "original".equalsIgnoreCase(molOpt))
        outMol = OUTMolFormat.ORIGINAL;
    else if ("NORMALIZED".equalsIgnoreCase(molOpt))
        outMol = OUTMolFormat.NORMALIZED;
    else if ("TAUTOMERIC".equalsIgnoreCase(molOpt))
        outMol = OUTMolFormat.TAUTOMERIC;
    else {
        System.err.printf("Unkown option for -mol: %s\n", molOpt);
        System.exit(1);
    }

    String inFile = cmd.getOptionValue("in");
    String outFile = cmd.getOptionValue("out");
    boolean limitMessage = cmd.hasOption("shortMessage");

    try {
        oemolistream ifs = new oemolistream(inFile);
        oemolostream ofs = new oemolostream(outFile);

        URL cFile = OEStruchk.getResourceURL(OEStruchk.class, "Struchk.xml");

        // create OEStruchk from config file
        OEStruchk strchk = new OEStruchk(cFile, CHECKConfig.ASSIGNStructFlag, false);

        OEGraphMol mol = new OEGraphMol();
        StringBuilder sb = new StringBuilder(2000);
        while (oechem.OEReadMolecule(ifs, mol)) {
            if (!strchk.applyRules(mol, null))
                nErrors++;

            switch (outMol) {
            case NORMALIZED:
                mol.Clear();
                oechem.OEAddMols(mol, strchk.getTransformedMol("parent"));
                break;
            case TAUTOMERIC:
                mol.Clear();
                oechem.OEAddMols(mol, strchk.getTransformedMol(null));
                break;
            case ORIGINAL:
                break;
            }

            oechem.OESetSDData(mol, "CTISMILES", strchk.getTransformedIsoSmiles(null));
            oechem.OESetSDData(mol, "CTSMILES", strchk.getTransformedSmiles(null));
            oechem.OESetSDData(mol, "CISMILES", strchk.getTransformedIsoSmiles("parent"));
            oechem.OESetSDData(mol, "Strutct_Flag", strchk.getStructureFlag().getName());

            List<Message> msgs = strchk.getStructureMessages(null);
            nMessages += msgs.size();
            for (Message msg : msgs)
                sb.append(String.format("\t%s:%s", msg.getLevel(), msg.getText()));
            if (limitMessage)
                sb.setLength(Math.min(sb.length(), 80));

            oechem.OESetSDData(mol, "NORM_MESSAGE", sb.toString());

            oechem.OEWriteMolecule(ofs, mol);

            sb.setLength(0);
            nStruct++;
        }
        strchk.delete();
        mol.delete();
        ifs.close();
        ifs.delete();
        ofs.close();
        ofs.delete();

    } catch (Exception e) {
        throw new Error(e);
    } finally {
        System.err.printf("sdfNormalizer: Checked %d structures %d errors, %d messages in %dsec\n", nStruct,
                nErrors, nMessages, (System.currentTimeMillis() - start) / 1000);
    }
}

From source file:com.dianping.dpsf.other.echo.EchoClient.java

/**
 * @param args//ww  w  . j a v a2 s .  com
 * @throws Exception 
 */
public static void main(String[] args) throws Exception {
    PigeonClientMock.setServiceAddress("127.0.0.1:20001,127.0.0.1:20002");
    ApplicationContext ctx = new ClassPathXmlApplicationContext("echo-client.xml");
    IEcho s = (IEcho) ctx.getBean("echo");
    //      System.out.println(s.echo("aa"));
    //      Thread.sleep(3000);
    //      System.out.println(s.echo("aa"));
    //      System.out.println("firing");
    Random rnd = new Random(System.currentTimeMillis());

    List<String[]> hostList = new ArrayList<String[]>();
    hostList.add(new String[] { "127.0.0.1", "20001", "1" });
    PigeonClientMock.getSc().onServiceHostChange("http://service.dianping.com/echoService", hostList);

    int i = 0;
    while (i < 100) {
        try {
            System.out.println(s.echo("aa"));
        } catch (Exception e) {
            System.out.println("EEEEEEEEEEEEEEEEEEEEEEE");
        }
        Thread.sleep(2000);
        if (i == 1) {
            System.out.println("+++++++++++++++++++adding 20002++++++++++++++++");
            hostList = new ArrayList<String[]>();
            hostList.add(new String[] { "127.0.0.1", "20001", "1" });
            hostList.add(new String[] { "127.0.0.1", "20002", "1" });
            PigeonClientMock.getSc().onServiceHostChange("http://service.dianping.com/echoService", hostList);
        }
        if (i == 5) {
            System.out.println("+++++++++++++++++++adding 20003++++++++++++++++");
            hostList = new ArrayList<String[]>();
            hostList.add(new String[] { "127.0.0.1", "20001", "1" });
            hostList.add(new String[] { "192.168.32.111", "20003", "1" });
            PigeonClientMock.getSc().onServiceHostChange("http://service.dianping.com/echoService", hostList);
        }
        if (i == 10) {
            System.out.println("--------------------change wt------------");
            PigeonClientMock.getSc().onHostWeightChange("127.0.0.1", 2);
        }
        i++;
    }

}

From source file:Main.java

public static void main(String[] args) {
    int maximum = 100;
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Integer[] oneRow = { 0, 0, 0, 0 };
    String[] headers = { "A", "B", "C", "D" };
    Integer[][] data = { oneRow, oneRow, oneRow, oneRow, oneRow, };
    DefaultTableModel model = new DefaultTableModel(data, headers);
    JTable table = new JTable(model);
    table.setDefaultRenderer(Object.class, new ProgressRenderer(0, maximum));
    table.setPreferredScrollableViewportSize(table.getPreferredSize());
    frame.add(new JScrollPane(table));
    frame.pack();/*from   ww  w.  j  a va  2 s  . co m*/
    frame.setVisible(true);
    new Thread(new Runnable() {
        @Override
        public void run() {
            Object waiter = new Object();
            synchronized (waiter) {
                int rows = model.getRowCount();
                int columns = model.getColumnCount();
                Random random = new Random(System.currentTimeMillis());
                boolean done = false;
                while (!done) {
                    int row = random.nextInt(rows);
                    int column = random.nextInt(columns);
                    Integer value = (Integer) model.getValueAt(row, column);
                    value++;
                    if (value <= maximum) {
                        model.setValueAt(value, row, column);
                        try {
                            waiter.wait(15);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                    done = true;
                    for (row = 0; row < rows; row++) {
                        for (column = 0; column < columns; column++) {
                            if (!model.getValueAt(row, column).equals(maximum)) {
                                done = false;
                                break;
                            }
                        }
                        if (!done) {
                            break;
                        }
                    }
                }
            }
        }
    }).start();
}