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.ppollack.symphony.faqbot.SymphonyFaqbotApp.java

public static void main(String[] args) {
    long start = System.currentTimeMillis();
    LOG.info(SymphonyFaqbotApp.class.getSimpleName() + " starting");

    // this will initialize SymphonyFaqbot and all of its dependencies
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("/spring-appcontext.xml");
    context.getBean(SymphonyFaqbot.class).start();

    LOG.info(SymphonyFaqbotApp.class.getSimpleName() + " started in " + (System.currentTimeMillis() - start)
            + "ms");
}

From source file:com.ipcglobal.awscdh.config.ManageCluster.java

/**
 * The main method./*  w w  w .  j av  a2  s.  c  o  m*/
 *
 * @param args the arguments
 * @throws Exception the exception
 */
public static void main(String[] args) throws Exception {
    try {
        long before = System.currentTimeMillis();
        LogTool.initConsole();
        if (args.length <= 1)
            throw new Exception(
                    "Action and Properties file name are required parameter - format: start|stop example.properties");
        String action = args[0];
        log.info("Begin: action=" + action);
        Properties properties = new Properties();
        properties.load(new FileInputStream(args[1]));
        ManageEc2 manageEc2 = new ManageEc2(properties);
        ManageCdh manageCdh = new ManageCdh(properties);

        if ("start".equals(action)) {
            manageEc2.start();
            manageCdh.start();
        } else if ("stop".equals(action)) {
            manageCdh.stop();
            manageEc2.stop();
        } else
            throw new Exception("Invalid action: " + action + ", must be start or stop");

        log.info("Complete: action=" + action + ", elapsed "
                + Utils.convertMSecsToHMmSs(System.currentTimeMillis() - before));

    } catch (Exception e) {
        log.error(e);
        e.printStackTrace();
    }
}

From source file:com.sangupta.nutz.RandomProcessorTest.java

public static void main(String[] args) throws Exception {
    String fileName = "markdown syntax - basics";
    // fileName = "tabs";
    String s3 = "src/test/resources/markdown/" + fileName + ".text";
    String o3 = "src/test/resources/markdown/" + fileName + ".html";

    File file = new File(s3);
    String markup = FileUtils.readFileToString(file);

    MarkdownProcessor processor = new MarkdownProcessor();

    for (int i = 0; i < 20; i++) {
        long start = System.currentTimeMillis();
        String html = processor.toHtml(markup);
        long end = System.currentTimeMillis();

        System.out.println("Time taken in emitting HTML: " + (end - start) + " ms.");

        String out = FileUtils.readFileToString(new File(o3));
        boolean htmlEquals = HTMLComparer.compareHtml(out, html);
        System.out.println("HTML Equals: " + htmlEquals);
    }/*ww  w.ja  v  a  2 s .  c om*/
}

From source file:ReflexiveInvocation.java

/**
 * Main demo method./*www  . j a  v a  2s.  co  m*/
 * 
 * @param args
 *          the command line arguments
 * 
 * @throws RuntimeException
 *           __UNDOCUMENTED__
 */
public static void main(final String[] args) {
    try {
        final int CALL_AMOUNT = 1000000;
        final ReflexiveInvocation ri = new ReflexiveInvocation();
        int idx = 0;

        // Call the method without using reflection.
        long millis = System.currentTimeMillis();

        for (idx = 0; idx < CALL_AMOUNT; idx++) {
            ri.getValue();
        }

        System.out.println("Calling method " + CALL_AMOUNT + " times programatically took "
                + (System.currentTimeMillis() - millis) + " millis");

        // Call while looking up the method in each iteration.
        Method md = null;
        millis = System.currentTimeMillis();

        for (idx = 0; idx < CALL_AMOUNT; idx++) {
            md = ri.getClass().getMethod("getValue", null);
            md.invoke(ri, null);
        }

        System.out.println("Calling method " + CALL_AMOUNT + " times reflexively with lookup took "
                + (System.currentTimeMillis() - millis) + " millis");

        // Call using a cache of the method.
        md = ri.getClass().getMethod("getValue", null);
        millis = System.currentTimeMillis();

        for (idx = 0; idx < CALL_AMOUNT; idx++) {
            md.invoke(ri, null);
        }

        System.out.println("Calling method " + CALL_AMOUNT + " times reflexively with cache took "
                + (System.currentTimeMillis() - millis) + " millis");
    } catch (final NoSuchMethodException ex) {
        throw new RuntimeException(ex);
    } catch (final InvocationTargetException ex) {
        throw new RuntimeException(ex);
    } catch (final IllegalAccessException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:org.fabric3.samples.hibernate.HibernateClient.java

public static void main(String[] args) {
    Message message = new Message();
    message.setText("Test message " + System.currentTimeMillis());

    Client client = ClientBuilder.newClient();
    client.register(JacksonJaxbJsonProvider.class);

    // set basic auth filter
    HttpBasicAuthFilter filter = new HttpBasicAuthFilter("foo", "bar");
    client.register(filter);// www  .j av a  2 s  .  c o m

    UriBuilder uri = UriBuilder.fromUri(BASE_URI);
    WebTarget target = client.target(uri.path("message").build());

    System.out.println("Creating message");
    Response r = target.request(MediaType.APPLICATION_JSON)
            .post(Entity.entity(message, MediaType.APPLICATION_JSON));
    String location = (String) r.getHeaders().get("location").get(0);

    target = client.target(BASE_URI + "/message/" + location);

    Message response = target.request(MediaType.APPLICATION_JSON).get(Message.class);

    WebTarget messagesResource = client.target(BASE_URI);
    MessageList messages = messagesResource.request(MediaType.APPLICATION_JSON).get(MessageList.class);
    for (Message entry : messages.getMessages()) {
        System.out.println("The message text for id " + entry.getId() + " is: " + entry.getText());
    }

    // resource.delete();
}

From source file:com.cloudhopper.sxmp.PostMO.java

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

    String URL = "https://sms.twitter.com/receive/cloudhopper";
    String text = "HELP";
    String srcAddr = "+16504304922";

    String ticketId = System.currentTimeMillis() + "";
    String operatorId = "20";

    StringBuilder string0 = new StringBuilder(200).append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n")
            .append("<operation type=\"deliver\">\n")
            .append(" <account username=\"customer1\" password=\"password1\"/>\n").append(" <deliverRequest>\n")
            .append("  <operatorId>" + operatorId + "</operatorId>\n")
            .append("  <sourceAddress type=\"international\">" + srcAddr + "</sourceAddress>\n")
            .append("  <destinationAddress type=\"network\">40404</destinationAddress>\n")
            .append("  <text encoding=\"ISO-8859-1\">" + HexUtil.toHexString(text.getBytes()) + "</text>\n")
            .append(" </deliverRequest>\n").append("</operation>\n").append("");

    HttpClient client = new DefaultHttpClient();
    client.getParams().setBooleanParameter("http.protocol.expect-continue", false);

    long start = System.currentTimeMillis();

    // execute request
    try {//from  w w  w.  j  a  v a 2s.  c  om
        HttpPost post = new HttpPost(URL);

        StringEntity entity = new StringEntity(string0.toString(), "ISO-8859-1");
        entity.setContentType("text/xml; charset=\"ISO-8859-1\"");
        post.setEntity(entity);

        ResponseHandler<String> responseHandler = new BasicResponseHandler();

        String responseBody = client.execute(post, responseHandler);

        logger.debug("----------------------------------------");
        logger.debug(responseBody);
        logger.debug("----------------------------------------");
    } finally {
        // do nothing
    }

    long end = System.currentTimeMillis();

    logger.debug("Response took " + (end - start) + " ms");

}

From source file:com.taobao.ad.easyschedule.server.JobHttpServer.java

public static void main(String[] args) throws Exception {
    long start = System.currentTimeMillis();
    System.out.println("DATASOURCE_CONTEXT_PATH:" + Const.DATASOURCE_CONTEXT_PATH);
    System.out.println("SERVER_CONTEXT:" + Const.SERVER_CONTEXT);
    System.out.println("SERVER_PORT:" + Const.SERVER_PORT);
    JobHttpServer server = new JobHttpServer();
    server.start();//from  www . j av  a  2s  . com
    System.out.println("es-httpserver-agent startup in " + (System.currentTimeMillis() - start) + "ms.");
}

From source file:id3Crawler.java

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

    //Input for the directory to be searched.
    System.out.println("Please enter a directory: ");
    Scanner scanner = new Scanner(System.in);
    String input = scanner.nextLine();

    //Start a timer to calculate runtime
    startTime = System.currentTimeMillis();

    System.out.println("Starting scan...");

    //Files for output
    PrintWriter pw1 = new PrintWriter(new FileWriter("C:/Users/gbob3_000/Desktop/id3CrawlerOutput/Song.txt"));
    PrintWriter pw2 = new PrintWriter(new FileWriter("C:/Users/gbob3_000/Desktop/id3CrawlerOutput/Artist.txt"));
    PrintWriter pw3 = new PrintWriter(new FileWriter("C:/Users/gbob3_000/Desktop/id3CrawlerOutput/Album.txt"));
    PrintWriter pw4 = new PrintWriter(
            new FileWriter("C:/Users/gbob3_000/Desktop/id3CrawlerOutput/PerformedBy.txt"));
    PrintWriter pw5 = new PrintWriter(
            new FileWriter("C:/Users/gbob3_000/Desktop/id3CrawlerOutput/TrackOf.txt"));
    PrintWriter pw6 = new PrintWriter(
            new FileWriter("C:/Users/gbob3_000/Desktop/id3CrawlerOutput/CreatedBy.txt"));

    //This is used for creating IDs for artists, songs, albums.
    int idCounter = 0;

    //This is used to prevent duplicate artists
    String previousArtist = " ";
    String currentArtist;//from w w w.ja v  a  2  s  . co  m
    int artistID = 0;

    //This is used to prevent duplicate albums
    String previousAlbum = " ";
    String currentAlbum;
    int albumID = 0;

    //This array holds valid extensions to iterate through
    String[] extensions = new String[] { "mp3" };

    //iterate through all files in a directory
    Iterator<File> it = FileUtils.iterateFiles(new File(input), extensions, true);
    while (it.hasNext()) {

        //open the next file
        File file = it.next();

        //instantiate an mp3file object with the opened file
        MP3 song = GetMP3(file);

        //pass the song through SongInfo and return the required information
        SongInfo info = new SongInfo(song);

        //This is used to prevent duplicate artists/albums
        currentArtist = info.getArtistInfo();
        currentAlbum = info.getAlbumInfo();

        //Append the song information to the end of a text file
        pw1.println(idCounter + "\t" + info.getTitleInfo());

        //This prevents duplicates of artists
        if (!(currentArtist.equals(previousArtist))) {
            pw2.println(idCounter + "\t" + info.getArtistInfo());
            previousArtist = currentArtist;
            artistID = idCounter;
        }

        //This prevents duplicates of albums
        if (!(currentAlbum.equals(previousAlbum))) {
            pw3.println(idCounter + "\t" + info.getAlbumInfo());
            previousAlbum = currentAlbum;
            albumID = idCounter;

            //This formats the IDs for a "CreatedBy" relationship table
            pw6.println(artistID + "\t" + albumID);
        }

        //This formats the IDs for a "PerformedBy" relationship table
        pw4.println(idCounter + "\t" + artistID);

        //This formats the IDs for a "TrackOf" relationship table
        pw5.println(idCounter + "\t" + albumID);

        idCounter++;
        songCounter++;

    }
    scanner.close();
    pw1.close();
    pw2.close();
    pw3.close();
    pw4.close();
    pw5.close();
    pw6.close();

    System.out.println("Scan took " + ((System.currentTimeMillis() - startTime) / 1000.0) + " seconds to scan "
            + songCounter + " items!");

}

From source file:Main.java

public static void main(String[] args) {
    long begTime = System.currentTimeMillis();

    String driver = DEFAULT_DRIVER;
    String url = DEFAULT_URL;
    String username = DEFAULT_USERNAME;
    String password = DEFAULT_PASSWORD;

    Connection connection = null;

    try {//from  w  w w  . j av  a 2s  .  c o m
        connection = createConnection(driver, url, username, password);
        DatabaseMetaData meta = connection.getMetaData();
        System.out.println(meta.getDatabaseProductName());
        System.out.println(meta.getDatabaseProductVersion());

        String sqlQuery = "SELECT PERSON_ID, FIRST_NAME, LAST_NAME FROM PERSON";
        System.out.println("before insert: " + query(connection, sqlQuery, Collections.EMPTY_LIST));

        connection.setAutoCommit(false);
        String sqlUpdate = "INSERT INTO PERSON(FIRST_NAME, LAST_NAME) VALUES(?,?)";
        List parameters = Arrays.asList("Foo", "Bar");
        int numRowsUpdated = update(connection, sqlUpdate, parameters);
        connection.commit();

        System.out.println("# rows inserted: " + numRowsUpdated);
        System.out.println("after insert: " + query(connection, sqlQuery, Collections.EMPTY_LIST));
    } catch (Exception e) {
        rollback(connection);
        e.printStackTrace();
    } finally {
        close(connection);
        long endTime = System.currentTimeMillis();
        System.out.println("wall time: " + (endTime - begTime) + " ms");
    }
}

From source file:com.hp.mqm.atrf.Main.java

public static void main(String[] args) {

    long start = System.currentTimeMillis();
    setUncaughtExceptionHandler();/*from www.j a  va2 s .com*/

    CliParser cliParser = new CliParser();
    cliParser.handleHelpAndVersionOptions(args);

    configureLog4J();
    logger.info(System.lineSeparator() + System.lineSeparator());
    logger.info("************************************************************************************");
    DateFormat dateFormatter = DateFormat.getDateInstance(DateFormat.DEFAULT, Locale.getDefault());
    DateFormat timeFormatter = DateFormat.getTimeInstance(DateFormat.DEFAULT, Locale.getDefault());
    logger.info((String.format("Starting HPE ALM Test Result Collection Tool %s %s",
            dateFormatter.format(new Date()), timeFormatter.format(new Date()))));
    logger.info("************************************************************************************");

    FetchConfiguration configuration = cliParser.parse(args);
    ConfigurationUtilities.setConfiguration(configuration);

    App app = new App(configuration);
    app.start();

    long end = System.currentTimeMillis();
    logger.info(String.format("Finished creating tests and test results on ALM Octane in %s seconds",
            (end - start) / 1000));
    logger.info(System.lineSeparator());
}