Search in sources :

Example 11 with StopWatch

use of org.apache.commons.lang3.time.StopWatch in project Java-Tutorial by gpcodervn.

the class LargeDataSerializerStreamingTest method main.

public static void main(final String[] args) throws IOException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    // Configure GSON
    final GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.registerTypeAdapter(LargeData.class, new LargeDataSerializer());
    gsonBuilder.setPrettyPrinting();
    final Gson gson = gsonBuilder.create();
    final LargeData data = new LargeData();
    data.create(10485760);
    final File dir = new File("data");
    dir.mkdirs();
    try (OutputStream os = new FileOutputStream(new File(dir, "outputSerialiserStreaming.json"));
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"))) {
        gson.toJson(data, out);
    }
    stopWatch.stop();
    System.out.println("Done in " + stopWatch.getTime());
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream) Gson(com.google.gson.Gson) LargeData(com.gpcoder.gson.object.LargeData) OutputStreamWriter(java.io.OutputStreamWriter) File(java.io.File) StopWatch(org.apache.commons.lang3.time.StopWatch) BufferedWriter(java.io.BufferedWriter)

Example 12 with StopWatch

use of org.apache.commons.lang3.time.StopWatch in project Java-Tutorial by gpcodervn.

the class LargeDataSerializerTest method main.

public static void main(final String[] args) throws IOException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    // Configure GSON
    final GsonBuilder gsonBuilder = new GsonBuilder();
    gsonBuilder.registerTypeAdapter(LargeData.class, new LargeDataSerializer());
    gsonBuilder.setPrettyPrinting();
    final Gson gson = gsonBuilder.create();
    final LargeData data = new LargeData();
    data.create(10485760);
    final String json = gson.toJson(data);
    final File dir = new File("data");
    dir.mkdirs();
    try (PrintStream out = new PrintStream(new File(dir, "outputSerialiser.json"), "UTF-8")) {
        out.println(json);
    }
    stopWatch.stop();
    System.out.println("Done in " + stopWatch.getTime());
}
Also used : PrintStream(java.io.PrintStream) GsonBuilder(com.google.gson.GsonBuilder) Gson(com.google.gson.Gson) LargeData(com.gpcoder.gson.object.LargeData) File(java.io.File) StopWatch(org.apache.commons.lang3.time.StopWatch)

Example 13 with StopWatch

use of org.apache.commons.lang3.time.StopWatch in project Java-Tutorial by gpcodervn.

the class WriteExcelExample method main.

public static void main(String[] args) throws IOException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    final List<Book> books = getBooks();
    final String excelFilePath = "C:/demo/books.xlsx";
    writeExcel(books, excelFilePath);
    System.out.println("Total times: " + stopWatch.getTime());
}
Also used : StopWatch(org.apache.commons.lang3.time.StopWatch)

Example 14 with StopWatch

use of org.apache.commons.lang3.time.StopWatch in project Java-Tutorial by gpcodervn.

the class WriteExcelUsingSXSSF method main.

public static void main(String[] args) throws IOException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    final List<Book> books = getBooks();
    final String excelFilePath = "C:/demo/books_large.xlsx";
    writeExcel(books, excelFilePath);
    System.out.println("Total times: " + stopWatch.getTime());
}
Also used : StopWatch(org.apache.commons.lang3.time.StopWatch)

Example 15 with StopWatch

use of org.apache.commons.lang3.time.StopWatch in project Java-Tutorial by gpcodervn.

the class StringConcatenate method main.

public static void main(String[] args) {
    StopWatch stopwatch = new StopWatch();
    // Concat string using String Object
    stopwatch.start();
    stringConcat();
    stopwatch.stop();
    System.out.println("time taken by StringBuilder : " + stopwatch.getNanoTime() + " nanoseconds");
    // Concat string using StringBuilder
    stopwatch.reset();
    stopwatch.start();
    stringBuilder();
    stopwatch.stop();
    System.out.println("time taken by StringBuilder : " + stopwatch.getNanoTime() + " nanoseconds");
    // Concat string using StringBuffer
    stopwatch.reset();
    stopwatch.start();
    stringBuffer();
    stopwatch.stop();
    System.out.println("time taken by StringBuffer : " + stopwatch.getNanoTime() + " nanoseconds");
}
Also used : StopWatch(org.apache.commons.lang3.time.StopWatch)

Aggregations

StopWatch (org.apache.commons.lang3.time.StopWatch)500 Test (org.junit.Test)149 EventResult (org.alfresco.bm.event.EventResult)97 DBObject (com.mongodb.DBObject)90 Event (org.alfresco.bm.event.Event)87 FolderData (org.alfresco.bm.cm.FolderData)75 File (java.io.File)72 ArrayList (java.util.ArrayList)48 HashSet (java.util.HashSet)31 Gene (ubic.gemma.model.genome.Gene)31 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)26 BaseTest (org.umlg.sqlg.test.BaseTest)26 Element (org.w3c.dom.Element)25 LoadSingleComponentUnitTest (org.alfresco.bm.dataload.LoadSingleComponentUnitTest)23 UserModel (org.alfresco.utility.model.UserModel)23 IOException (java.io.IOException)20 Collectors (java.util.stream.Collectors)19 HashMap (java.util.HashMap)18 List (java.util.List)18 ExpressionExperiment (ubic.gemma.model.expression.experiment.ExpressionExperiment)18