Example usage for org.apache.commons.lang.time StopWatch toSplitString

List of usage examples for org.apache.commons.lang.time StopWatch toSplitString

Introduction

In this page you can find the example usage for org.apache.commons.lang.time StopWatch toSplitString.

Prototype

public String toSplitString() 

Source Link

Document

Gets a summary of the split time that the stopwatch recorded as a string.

The format used is ISO8601-like, hours:minutes:seconds.milliseconds.

Usage

From source file:de.pro.dbw.application.testdata.service.ReflectionService.java

@Override
protected Task<Void> createTask() {
    return new Task<Void>() {
        {/*  ww  w  . j  av a  2 s  .  c om*/
            updateProgress(0, saveMaxEntities);
        }

        @Override
        protected Void call() throws Exception {
            LoggerFacade.INSTANCE.deactivate(Boolean.TRUE);

            final StopWatch stopWatch = new StopWatch();
            stopWatch.start();

            final ICrudService crudService = DatabaseFacade.INSTANCE.getCrudService(entityName);
            long id = -1_000_000_000L + DatabaseFacade.INSTANCE.getCrudService().count(entityName);
            for (int i = 1; i <= saveMaxEntities; i++) {
                crudService.beginTransaction();

                final ReflectionModel model = new ReflectionModel();
                model.setGenerationTime(ReflectionService.this.createGenerationTime());
                model.setId(id++);
                model.setTitle(LoremIpsum.getDefault().getTitle());
                model.setText(LoremIpsum.getDefault().getText());

                crudService.create(model, false);
                updateProgress(i - 1, saveMaxEntities);

                crudService.commitTransaction();
            }

            LoggerFacade.INSTANCE.deactivate(Boolean.FALSE);
            stopWatch.split();
            LoggerFacade.INSTANCE.debug(this.getClass(),
                    "  + " + stopWatch.toSplitString() + " for " + saveMaxEntities + " Reflections."); // NOI18N
            stopWatch.stop();

            return null;
        }
    };
}

From source file:de.pro.dbw.application.testdata.service.DreamService.java

@Override
protected Task<Void> createTask() {
    return new Task<Void>() {
        {//from   ww  w .jav a2 s . com
            updateProgress(0, saveMaxEntities);
        }

        @Override
        protected Void call() throws Exception {
            LoggerFacade.INSTANCE.deactivate(Boolean.TRUE);

            final StopWatch stopWatch = new StopWatch();
            stopWatch.start();

            final ICrudService crudService = DatabaseFacade.INSTANCE.getCrudService(entityName);
            long id = -1_000_000_000L + DatabaseFacade.INSTANCE.getCrudService().count(entityName);
            for (int i = 1; i <= saveMaxEntities; i++) {
                crudService.beginTransaction();

                final DreamModel model = new DreamModel();
                model.setGenerationTime(DreamService.this.createGenerationTime());
                model.setDescription(LoremIpsum.getDefault().getDescription());
                model.setId(id++);
                model.setTitle(LoremIpsum.getDefault().getTitle());
                model.setText(LoremIpsum.getDefault().getText());

                crudService.create(model, false);
                updateProgress(i - 1, saveMaxEntities);

                crudService.commitTransaction();
            }

            LoggerFacade.INSTANCE.deactivate(Boolean.FALSE);
            stopWatch.split();
            LoggerFacade.INSTANCE.debug(this.getClass(),
                    "  + " + stopWatch.toSplitString() + " for " + saveMaxEntities + " Dreams."); // NOI18N
            stopWatch.stop();

            return null;
        }
    };
}

From source file:de.pro.dbw.application.testdata.service.TipOfTheNightService.java

@Override
protected Task<Void> createTask() {
    return new Task<Void>() {
        {/*from   ww w  .ja  v  a2  s.co m*/
            updateProgress(0, saveMaxEntities);
        }

        @Override
        protected Void call() throws Exception {
            LoggerFacade.INSTANCE.deactivate(Boolean.TRUE);

            final StopWatch stopWatch = new StopWatch();
            stopWatch.start();

            final ICrudService crudService = DatabaseFacade.INSTANCE.getCrudService(entityName);
            //                crudService.beginTransaction();
            long id = -1_000_000_000L + DatabaseFacade.INSTANCE.getCrudService().count(entityName);
            for (int i = 1; i <= saveMaxEntities; i++) {
                crudService.beginTransaction();

                final TipOfTheNightModel model = new TipOfTheNightModel();
                model.setGenerationTime(TipOfTheNightService.this.createGenerationTime());
                model.setId(id++);
                model.setTitle(LoremIpsum.getDefault().getTitle());
                model.setText(LoremIpsum.getDefault()
                        .getTextWithMaxEntries(LoremIpsum.MAX_ENTRIES_FOR__TIP_OF_THE_NIGHT));

                crudService.create(model, false);
                updateProgress(i - 1, saveMaxEntities);

                crudService.commitTransaction();
                //                    if (i % 250 == 0) {
                //                        crudService.commitTransaction();
                //                        crudService.beginTransaction();
                //                    }
            }

            //                crudService.commitTransaction();

            LoggerFacade.INSTANCE.deactivate(Boolean.FALSE);
            stopWatch.split();
            LoggerFacade.INSTANCE.debug(this.getClass(),
                    "  + " + stopWatch.toSplitString() + " for " + saveMaxEntities + " TipOfTheNights."); // NOI18N
            stopWatch.stop();

            return null;
        }
    };
}

From source file:org.trend.hgraph.VariousTest.java

@Test
@Ignore //for test StopWatch behavior
public void testStopWatch() throws InterruptedException {
    StopWatch timer = new StopWatch();

    // #1/* w w  w. j av a 2s  . co  m*/
    timer.start();
    Thread.sleep(5000);
    timer.stop();

    System.out.println("timer.toString=" + timer.toString());
    //    System.out.println("timer.toSplitString=" + timer.toSplitString());

    // #2
    timer.reset();
    timer.start();
    Thread.sleep(4000);
    timer.split();
    System.out.println("timer.toSplitString=" + timer.toSplitString());
    Thread.sleep(5000);
    timer.split();
    System.out.println("timer.toSplitString=" + timer.toSplitString());
    timer.unsplit();
    Thread.sleep(6000);
    timer.stop();

    System.out.println("timer.toString=" + timer.toString());

}