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());
}
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());
}
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());
}
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());
}
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");
}
Aggregations