public ParallelTest() {
    StopWatch watch = new StopWatch("Timer");
    List<Integer> numbersToSum = new ArrayList<Integer>();

    System.out.println("Preparing data...");
    for (int i = 0; i < 1_000_000; i++) {
      numbersToSum.add(i);
    }
    System.out.println("Data prepared");
    watch.start("Parallel sum");
    Long sum = numbersToSum.stream().parallel().map(it -> it.longValue()).reduce(0L, Long::sum);
    watch.stop();

    watch.start("Sequence sum");
    sum = numbersToSum.stream().map(it -> it.longValue()).reduce(0L, Long::sum);
    watch.stop();

    Long[] arrayOfLong = new Long[20_000_000];
    // prepare array
    Arrays.parallelSetAll(arrayOfLong, it -> ThreadLocalRandom.current().nextLong(100_000));

    // make a copy
    Long[] arrayOfLongCopy = Arrays.copyOf(arrayOfLong, arrayOfLong.length);

    // print array
    Arrays.stream(arrayOfLong).limit(10).forEach(it -> System.out.print(it + ", "));
    System.out.println();
    watch.start("Parallel sort");
    // sort array and print
    Arrays.parallelSort(arrayOfLong);
    watch.stop();
    Arrays.stream(arrayOfLong).limit(10).forEach(it -> System.out.print(it + ", "));
    System.out.println();
    watch.start("Seq sort");
    Arrays.sort(arrayOfLongCopy);
    watch.stop();
    Arrays.stream(arrayOfLongCopy).limit(10).forEach(it -> System.out.print(it + ", "));

    System.out.println(watch.prettyPrint());
  }
 @Override
 public boolean execute() {
   boolean retVal = true;
   StopWatch watch = new StopWatch();
   try {
     watch.start();
     LOGGER.debug("In generator");
     TenantBlobSizeQueue queue = (TenantBlobSizeQueue) getWorkQueue();
     // get all tenantIds
     List<TenantIdMasterEntity> listTenant = tenantIdMasterDao.getAllTenants();
     for (Iterator<TenantIdMasterEntity> iterator = listTenant.iterator(); iterator.hasNext(); ) {
       TenantIdMasterEntity tenant = (TenantIdMasterEntity) iterator.next();
       String tenantId = tenant.getTenantId();
       // put each tenant Id in queue
       queue.enqueue(tenantId);
       LOGGER.info("Generator : msg added is " + tenantId);
     }
     watch.stop();
     taskCompletionDao.updateTaskCompletionDetails(
         watch.getTotalTimeSeconds(),
         "GenerateMeterBlobSizeWork",
         "Measure blob size for " + listTenant.size() + " tenants");
   } catch (StorageException e) {
     retVal = false;
     LOGGER.error(e.getMessage(), e);
   }
   return retVal;
 }
 @Override
 public boolean execute() {
   boolean retval = true;
   try {
     TenantCreationQueue tntCreationQueue = (TenantCreationQueue) getWorkQueue();
     String message = tntCreationQueue.dequeue(SchedulerSettings.MessageVisibilityTimeout);
     if (message == null) {
       LOGGER.debug("Msg is null");
       retval = false;
     } else {
       StopWatch watch = new StopWatch();
       watch.start();
       ProvisioningTenantDTO provisioningTenantDTO = createDTOfromMessage(message);
       boolean tenantCreationSuccess = provisioningService.provisionTenant(provisioningTenantDTO);
       if (tenantCreationSuccess) {
         LOGGER.debug("tenant created :" + provisioningTenantDTO.getTenantId());
       } else {
         LOGGER.debug(
             "tenant creation for tenant ID :" + provisioningTenantDTO.getTenantId() + " failed.");
       }
       watch.stop();
       taskCompletionDao.updateTaskCompletionDetails(
           watch.getTotalTimeSeconds(),
           "ProvisionTenantWork",
           "Tenant " + provisioningTenantDTO.getTenantId() + " is created.");
     }
   } catch (StorageException e) {
     retval = false;
     LOGGER.error(e.getMessage(), e);
   }
   return retval;
 }
Esempio n. 4
0
  /**
   * Runs the scrubber process.
   *
   * @param jobName the name of the job this step is being run as part of
   * @param jobRunDate the time/date the job was started
   * @return true if the job completed successfully, false if otherwise
   * @see org.kuali.kfs.sys.batch.Step#execute(java.lang.String)
   */
  public boolean execute(String jobName, Date jobRunDate) {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start(jobName);
    String inputFile =
        batchFileDirectoryName
            + File.separator
            + GeneralLedgerConstants.BatchFileSystem.ICR_TRANSACTIONS_OUTPUT_FILE
            + GeneralLedgerConstants.BatchFileSystem.EXTENSION;
    String outputFile =
        batchFileDirectoryName
            + File.separator
            + GeneralLedgerConstants.BatchFileSystem.ICR_POSTER_INPUT_FILE
            + GeneralLedgerConstants.BatchFileSystem.EXTENSION;

    BatchSortUtil.sortTextFileWithFields(inputFile, outputFile, new PosterSortComparator());

    stopWatch.stop();
    if (LOG.isDebugEnabled()) {
      LOG.debug(
          "IcrSort step of "
              + jobName
              + " took "
              + (stopWatch.getTotalTimeSeconds() / 60.0)
              + " minutes to complete");
    }
    return true;
  }
Esempio n. 5
0
  public static void main(String[] args) {
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("AC-test.xml");
    IRuleEngine ruleEngine = ctx.getBean("ruleEngine", IRuleEngine.class);

    System.out.println(ruleEngine.getRulePackages());

    //		ruleEngine.execute("p2", "1");

    PremiumCalcBom bom = new PremiumCalcBom();
    bom.setInsuredSex("F");
    bom.setInsPeriodUnit("Y");
    bom.setInsPeriod("10");
    bom.setPayMode("T");
    bom.setAmount(10000.0);
    bom.setInsuredBirthday("1990-01-01");

    System.out.println("start");

    StopWatch sw = new StopWatch();
    sw.start();
    //		for (int j = 0; j < 10000; j++) {
    for (int i = 80; i < 90; i++) {
      bom.setInsuredBirthday("19" + i + "-01-01");
      int r = ruleEngine.execute("com.enci.ecp.bizprocess.product.rule.premiumcalc_00177000", bom);
      //			System.out.println(bom.getTotalPremium());
    }
    //		}
    sw.stop();
    System.out.println(sw.prettyPrint());
  }
 @Override
 protected void doFilterInternal(
     HttpServletRequest request, HttpServletResponse response, FilterChain chain)
     throws ServletException, IOException {
   UrlPathHelper helper = new UrlPathHelper();
   String suffix = helper.getPathWithinApplication(request);
   StopWatch stopWatch = new StopWatch();
   stopWatch.start();
   try {
     chain.doFilter(request, response);
   } finally {
     stopWatch.stop();
     int status = getStatus(response);
     Object bestMatchingPattern =
         request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
     HttpStatus httpStatus = HttpStatus.OK;
     try {
       httpStatus = HttpStatus.valueOf(status);
     } catch (Exception ex) {
       // not convertible
     }
     if (bestMatchingPattern != null) {
       suffix = bestMatchingPattern.toString().replaceAll("[{}]", "-");
     } else if (httpStatus.is4xxClientError()) {
       suffix = UNKNOWN_PATH_SUFFIX;
     }
     String gaugeKey = getKey("response" + suffix);
     MetricFilterAutoConfiguration.this.gaugeService.submit(
         gaugeKey, stopWatch.getTotalTimeMillis());
     String counterKey = getKey("status." + status + suffix);
     MetricFilterAutoConfiguration.this.counterService.increment(counterKey);
   }
 }
  /** Swagger Springfox configuration. */
  @Bean
  @Profile("!" + Constants.SPRING_PROFILE_FAST)
  public Docket swaggerSpringfoxDocket(JHipsterProperties jHipsterProperties) {
    log.debug("Starting Swagger");
    StopWatch watch = new StopWatch();
    watch.start();
    ApiInfo apiInfo =
        new ApiInfo(
            jHipsterProperties.getSwagger().getTitle(),
            jHipsterProperties.getSwagger().getDescription(),
            jHipsterProperties.getSwagger().getVersion(),
            jHipsterProperties.getSwagger().getTermsOfServiceUrl(),
            jHipsterProperties.getSwagger().getContact(),
            jHipsterProperties.getSwagger().getLicense(),
            jHipsterProperties.getSwagger().getLicenseUrl());

    Docket docket =
        new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(apiInfo)
            .genericModelSubstitutes(ResponseEntity.class)
            .forCodeGeneration(true)
            .genericModelSubstitutes(ResponseEntity.class)
            .ignoredParameterTypes(Pageable.class)
            .directModelSubstitute(java.time.LocalDate.class, String.class)
            .directModelSubstitute(java.time.ZonedDateTime.class, Date.class)
            .directModelSubstitute(java.time.LocalDateTime.class, Date.class)
            .select()
            .paths(regex(DEFAULT_INCLUDE_PATTERN))
            .build();
    watch.stop();
    log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis());
    return docket;
  }
  private BibTrees fetchResultSet(int batchSize, BatchStatistics batchStatistics, Boolean isBibOnly)
      throws Exception {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    BibTrees bibTrees = new BibTrees();
    int count = 0;
    if (batchSize <= 0) {
      return bibTrees;
    }
    while (bibResultSet.next()) {
      count++;
      BibTree bibTree = new BibTree();
      Bib bib = fetchBibRecord();
      bibTree.setBib(bib);
      if (!isBibOnly) {
        List<HoldingsTree> holdingsList =
            fetchHoldingsTreeForBib(Integer.parseInt(bib.getLocalId()));
        bibTree.getHoldingsTrees().addAll(holdingsList);
        batchStatistics.addHoldingsCount(holdingsList.size());

        for (HoldingsTree holdingsTree : holdingsList) {
          batchStatistics.addItemCount(holdingsTree.getItems().size());
        }
      }

      bibTrees.getBibTrees().add(bibTree);
      if (count == batchSize) {
        break;
      }
    }
    stopWatch.stop();
    batchStatistics.addTimeTaken(stopWatch.getTotalTimeMillis());
    batchStatistics.addBibCount(bibTrees.getBibTrees().size());
    return bibTrees;
  }
 protected void initDb() throws LiquibaseException {
   StopWatch watch = new StopWatch();
   watch.start();
   super.afterPropertiesSet();
   watch.stop();
   log.debug("Started Liquibase in {} ms", watch.getTotalTimeMillis());
 }
Esempio n. 10
0
 protected SmiMib getMib() {
   // this is a rather ugly hack to mimic JUnit4 @BeforeClass, without having to annotate all test
   // methods:
   if (m_mib.get() == null || m_testClass.get() != getClass()) {
     try {
       SmiParser parser = createParser();
       StopWatch stopWatch = new StopWatch();
       stopWatch.start();
       SmiMib mib = parser.parse();
       stopWatch.stop();
       m_log.info("Parsing time: " + stopWatch.getTotalTimeSeconds() + " s");
       if (mustParseSuccessfully()) {
         assertTrue(((SmiDefaultParser) parser).getProblemEventHandler().isOk());
         assertEquals(
             0,
             ((SmiDefaultParser) parser)
                 .getProblemEventHandler()
                 .getSeverityCount(ProblemSeverity.ERROR));
       }
       m_mib.set(mib);
       m_testClass.set(getClass());
     } catch (Exception e) {
       throw new RuntimeException(e);
     }
   }
   return m_mib.get();
 }
 @Test
 public void prototypeCreationIsFastEnough() {
   if (factoryLog.isTraceEnabled() || factoryLog.isDebugEnabled()) {
     // Skip this test: Trace logging blows the time limit.
     return;
   }
   GenericApplicationContext ac = new GenericApplicationContext();
   RootBeanDefinition rbd = new RootBeanDefinition(TestBean.class);
   rbd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);
   rbd.getConstructorArgumentValues().addGenericArgumentValue("#{systemProperties.name}");
   rbd.getPropertyValues().add("country", "#{systemProperties.country}");
   ac.registerBeanDefinition("test", rbd);
   ac.refresh();
   StopWatch sw = new StopWatch();
   sw.start("prototype");
   System.getProperties().put("name", "juergen");
   System.getProperties().put("country", "UK");
   try {
     for (int i = 0; i < 100000; i++) {
       TestBean tb = (TestBean) ac.getBean("test");
       assertEquals("juergen", tb.getName());
       assertEquals("UK", tb.getCountry());
     }
     sw.stop();
   } finally {
     System.getProperties().remove("country");
     System.getProperties().remove("name");
   }
   assertTrue(
       "Prototype creation took too long: " + sw.getTotalTimeMillis(),
       sw.getTotalTimeMillis() < 6000);
 }
Esempio n. 12
0
 // 同步所有服装款式
 @Scheduled(cron = "20 0 3 * * *")
 public void syncAllCloth() {
   StopWatch sw = new StopWatch();
   sw.start();
   logger.info("===>> 开始同步服装");
   this.henghuaService.syncAllCloth();
   sw.stop();
   logger.info("===>> 服装同步完毕,共耗时:" + sw.getTotalTimeMillis() + "ms");
 }
Esempio n. 13
0
 // 同步所有样品数据
 @Scheduled(cron = "10 0 3 * * *")
 public void syncAllSampleDetail() {
   StopWatch sw = new StopWatch();
   sw.start();
   logger.info("===>> 开始同步样品");
   this.henghuaService.syncAllSampleDetail();
   sw.stop();
   logger.info("===>> 样品同步完毕,共耗时:" + sw.getTotalTimeMillis() + "ms");
 }
 void report() {
   System.out.println(stopWatch.prettyPrint());
   for (StopWatch.TaskInfo taskInfo : stopWatch.getTaskInfo()) {
     String taskName = taskInfo.getTaskName();
     if (!taskName.startsWith("warmup")) {
       double nanosecs = taskInfo.getTimeMillis() * 1000000.0;
       double averagens = nanosecs / counts.get(taskName);
       System.out.println(taskName + ": avg time (ns) " + averagens);
     }
   }
 }
 @Around("methodsToBeProfiled()")
 public Object profile(ProceedingJoinPoint pjp) throws Throwable {
   StopWatch sw = new StopWatch(getClass().getSimpleName());
   try {
     sw.start(pjp.getSignature().getName());
     return pjp.proceed();
   } finally {
     sw.stop();
     System.out.println("############## Performance : " + sw.prettyPrint());
   }
 }
  @Override
  public Object invoke(MethodInvocation invocation) throws Throwable {
    final StopWatch stopWatch = new StopWatch(invocation.getMethod().toGenericString());
    stopWatch.start("invocation.proceed()");

    try {
      log.info(">>>>>>> START METHOD {} <<<<<<<<<", invocation.getMethod().toGenericString());
      return invocation.proceed();
    } finally {
      stopWatch.stop();
      log.info(stopWatch.prettyPrint());
      log.info(">>>>>>> END METHOD {} <<<<<<<<<", invocation.getMethod().toGenericString());
    }
  }
Esempio n. 17
0
 @Around("execution(* es.rubenjgarcia.aop.Foo.*(..))")
 public Object measureMethod(ProceedingJoinPoint pjp) throws Throwable {
   StopWatch sw = new StopWatch();
   Object retVal;
   try {
     sw.start(pjp.getTarget() + "." + pjp.getSignature());
     retVal = pjp.proceed();
   } catch (Throwable e) {
     throw e;
   } finally {
     sw.stop();
     System.out.println(sw.prettyPrint());
   }
   return retVal;
 }
  /**
   * Starting point of the chain, called by client or pre-node. Call <code>handle()</code> on this
   * node, and decide whether to continue the chain. If the next node is not null and this node did
   * not handle the request, call <code>start()</code> on next node to handle request.
   *
   * @param request the request object
   * @return a boolean indicates whether this handler fully handled the request
   * @see
   *     edu.utah.further.core.api.chain.RequestProcessor#process(edu.utah.further.core.api.chain.ChainRequest)
   */
  @Override
  public final boolean process(final ChainRequest request) {
    final StopWatch watch = new StopWatch();
    watch.start();
    final boolean handledByThisNode = processor.process(request);
    watch.stop();

    // Returns the average elapsed time of all calls to the handle() code
    // since the application comes up
    // this.elapsedTime = report.getAverageTime(); // report.getTotalTime();
    // logger.debug("Average analysis time (Stopwatch): "
    // + report.getAverageTime());

    this.elapsedTime = watch.getTotalTimeSeconds();
    return handledByThisNode;
  }
  /** Swagger Spring MVC configuration. */
  @Bean
  public SwaggerSpringMvcPlugin swaggerSpringMvcPlugin(SpringSwaggerConfig springSwaggerConfig) {
    log.debug("Starting Swagger");
    StopWatch watch = new StopWatch();
    watch.start();
    SwaggerSpringMvcPlugin swaggerSpringMvcPlugin =
        new SwaggerSpringMvcPlugin(springSwaggerConfig)
            .apiInfo(apiInfo())
            .genericModelSubstitutes(ResponseEntity.class)
            .includePatterns(DEFAULT_INCLUDE_PATTERN);

    swaggerSpringMvcPlugin.build();
    watch.stop();
    log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis());
    return swaggerSpringMvcPlugin;
  }
Esempio n. 20
0
 @Override
 protected void doFilterInternal(
     HttpServletRequest request, HttpServletResponse response, FilterChain chain)
     throws ServletException, IOException {
   StopWatch stopWatch = new StopWatch();
   stopWatch.start();
   String path = new UrlPathHelper().getPathWithinApplication(request);
   int status = HttpStatus.INTERNAL_SERVER_ERROR.value();
   try {
     chain.doFilter(request, response);
     status = getStatus(response);
   } finally {
     stopWatch.stop();
     recordMetrics(request, path, status, stopWatch.getTotalTimeMillis());
   }
 }
  /** Calculates the blob sizes of private and public container. */
  @Override
  public boolean execute() {
    boolean retVal = true;
    String tenantId = null;
    long blobSize = 0;
    try {
      LOGGER.debug("In Processor");
      TenantBlobSizeQueue queue = (TenantBlobSizeQueue) getWorkQueue();
      tenantId = queue.dequeue(SchedulerSettings.MessageVisibilityTimeout);
      if (tenantId == null) {
        retVal = false;
        LOGGER.debug("Processor : msg is null");
      } else {
        StopWatch watch = new StopWatch();
        watch.start();
        // get the size of blobs in private container.
        blobSize = storageUtility.getContainerSize("tntp-" + tenantId.toLowerCase());
        // get the size of blobs in public container.
        blobSize = blobSize + storageUtility.getContainerSize("tnts-" + tenantId.toLowerCase());
        LOGGER.debug("Processor : msg is " + tenantId);
        MeteringEntity metering = new MeteringEntity();
        metering.setTenantId(tenantId);

        Calendar calendar = Calendar.getInstance();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S z");
        dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        String date = dateFormat.format(calendar.getTime());
        metering.setSnapshotTime(dateFormat.parse(date));
        // set the calculated size
        blobSize = blobSize / 1024;
        metering.setBlobStoreUsage(blobSize);
        meteringDao.add(metering);
        LOGGER.info("Processor : blobSize is " + blobSize);
        watch.stop();
        taskCompletionDao.updateTaskCompletionDetails(
            watch.getTotalTimeSeconds(),
            "ProcessMeteringBlobSizes",
            "Measured " + blobSize + " kb for tenant " + tenantId);
      }
    } catch (Exception e) {
      retVal = false;
      LOGGER.error(e.getMessage(), e);
    }
    return retVal;
  }
Esempio n. 22
0
  @Around("execution(*sayHello())")
  public Object invoke(ProceedingJoinPoint arg0) throws Throwable {
    // 메서드가 실행되기전과 되고나서에 실행시간을 측정해줄 수 있다.
    StopWatch watch = new StopWatch();
    String methodName = arg0.getSignature().getName();

    watch.start(methodName);
    System.out.println("[LOG] method: " + methodName + "시작됨");

    Object obj = arg0.proceed(); // proceed 잠시멈췄던 메서드를 다시 실행 시킨다.

    watch.stop();
    long endTime = System.currentTimeMillis();
    System.out.println("[LOG]method: " + methodName + "종료");
    System.out.println("[LOG]처리시간 : " + watch.getTotalTimeSeconds());

    return obj;
  }
  private void runSerializationBenchmark(String taskName, PojoCodec codec, Object object)
      throws IOException {
    final byte[] buffer = new byte[1024];

    stopWatch.start(taskName);
    long start = System.currentTimeMillis();
    int count = 0;
    while (System.currentTimeMillis() - start < TEST_DURATION_MILLIS) {
      for (int i = 0; i < ITERATIONS; i++) {

        final Output output = new Output(buffer, -1);
        codec.serialize(object, output);
        count++;
      }
    }
    stopWatch.stop();
    counts.put(taskName, count);
  }
 private void runDeserializationBenchmark(String taskName, PojoCodec codec, Object object)
     throws IOException {
   ByteArrayOutputStream bos = new ByteArrayOutputStream();
   codec.serialize(object, bos);
   byte[] buffer = bos.toByteArray();
   int count = 0;
   stopWatch.start(taskName);
   long start = System.currentTimeMillis();
   count = 0;
   while (System.currentTimeMillis() - start < TEST_DURATION_MILLIS) {
     for (int i = 0; i < ITERATIONS; i++) {
       codec.deserialize(buffer, object.getClass());
       count++;
     }
   }
   stopWatch.stop();
   counts.put(taskName, count);
 }
Esempio n. 25
0
  @Around("execution(public * examples.account..*.*(..))")
  public Object invoke(ProceedingJoinPoint proceedingJointPoint) throws Throwable {

    String methodName = proceedingJointPoint.getSignature().getName();

    StopWatch stopWatch = new StopWatch();

    if (logger.isInfoEnabled()) {
      logger.info("calling : " + methodName + "()");

      Object[] args = proceedingJointPoint.getArgs();
      if ((args != null) && (args.length > 0)) {
        for (int i = 0; i < args.length; i++) {
          logger.info("Argument[" + i + "] : " + args[i]);
        }
      }
    }

    try {
      stopWatch.start(methodName);

      Object returnValue = proceedingJointPoint.proceed();

      stopWatch.stop();

      if (logger.isInfoEnabled()) {
        logger.info("return value : " + returnValue);
      }

      return returnValue;

    } catch (Throwable e) {
      if (logger.isErrorEnabled()) {
        e.printStackTrace();
      }
      throw e;
    } finally {
      if (logger.isInfoEnabled()) {
        logger.info("finish call : " + methodName + "()");
        logger.debug("time : " + stopWatch.getTotalTimeSeconds() + " seconds");
      }
    }
  }
  @Around("within(@org.springframework.stereotype.Repository *)")
  public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable {
    if (this.enabled) {
      StopWatch sw = new StopWatch(joinPoint.toShortString());

      sw.start("invoke");
      try {
        return joinPoint.proceed();
      } finally {
        sw.stop();
        synchronized (this) {
          this.callCount++;
          this.accumulatedCallTime += sw.getTotalTimeMillis();
        }
      }
    } else {
      return joinPoint.proceed();
    }
  }
 public Object profile(ProceedingJoinPoint pjp) throws Throwable {
   StopWatch stopWatch = new StopWatch();
   stopWatch.start(pjp.toShortString());
   boolean isException = false;
   try {
     return pjp.proceed();
   } catch (RuntimeException exception) {
     isException = true;
     throw exception;
   } finally {
     stopWatch.stop();
     TaskInfo taskInfo = stopWatch.getLastTaskInfo();
     System.out.println(
         taskInfo.getTaskName()
             + ": "
             + taskInfo.getTimeMillis()
             + " ms"
             + (isException ? " (thrown Exception)" : ""));
   }
 }
Esempio n. 28
0
 public static void main(String[] args) throws ParseException {
   StopWatch sw2 = new StopWatch();
   sw2.start();
   logger.info("Fare Start load spring configuration file ,Time= " + new Date());
   ClassPathXmlApplicationContext applicationcontext =
       new ClassPathXmlApplicationContext(
           new String[] {
             "spring/applicationContext-common.xml",
             "spring/applicationContext-db-ec.xml",
             "spring/applicationContext-dubbo.xml",
             "spring/applicationContext-mongodb.xml",
             "spring/applicationContext-cache-process.xml",
             "spring/applicationContext-db-tax.xml"
           });
   logger.info("Fare End Load spring conf configuration ,Time= " + new Date());
   // 启动http Server
   new EmbedHTTPServer(new DefaultHttpHandler(), FareContants.HTTP_PORT);
   sw2.stop();
   logger.info("Fare System Start Time :" + sw2.getTotalTimeMillis());
   sparkFare(applicationcontext);
   logger.info("Fare is Running....");
 }
  @Test
  public void testGetUser() throws Exception {
    StopWatch stopwatch = new StopWatch();
    stopwatch.start();

    GithubUser foo = githubService.getUser("foo");
    stopwatch.stop();

    long duration = stopwatch.getTotalTimeMillis();

    assertThat(foo).isNotNull();

    assertThat(foo.getUser()).isNotNull();
    assertThat(foo.getUser().getLogin()).isEqualTo("foo");
    assertThat(foo.getUser().getName()).isEqualTo("foo bar");

    assertThat(foo.getFollowers()).hasSize(3).extracting("name").contains("bar", "qix", "baz");
    assertThat(foo.getRepositories()).hasSize(2).extracting("name").contains("foo", "bar");

    // duration should be at least 300ms & max 400ms with overhead
    assertThat(duration).isGreaterThanOrEqualTo(300);
    assertThat(duration).isLessThanOrEqualTo(400);
  }
 @Override
 public boolean execute() {
   StopWatch watch = new StopWatch();
   boolean retVal = true;
   try {
     watch.start();
     LOGGER.debug("In generator");
     TenantDBBandwidthQueue queue = (TenantDBBandwidthQueue) getWorkQueue();
     Calendar calendar = Calendar.getInstance();
     SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S z");
     dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
     String currentTime = dateFormat.format(calendar.getTime());
     queue.enqueue(currentTime);
     LOGGER.info("Generator : msg added is " + currentTime);
     watch.stop();
     taskCompletionDao.updateTaskCompletionDetails(
         watch.getTotalTimeSeconds(), "GenerateMeterTenantDBBandwidthWork", "");
   } catch (StorageException e) {
     retVal = false;
     LOGGER.error(e.getMessage(), e);
   }
   return retVal;
 }