Examples of Performance


Examples of org.jboss.arquillian.performance.annotation.Performance

   {
      TestResult result = testResultInst.get();
      if(result != null)
      {
         //check if we have set a threshold
         Performance performance = null;
         Annotation[] annotations =  event.getTestMethod().getDeclaredAnnotations();
         for(Annotation a : annotations)
            if(a.annotationType().getName().equals(Performance.class.getCanonicalName()))
               performance = (Performance) a;
       
         if(performance != null)
         {
            if(performance.time() > 0 &&
               performance.time() < (result.getEnd()-result.getStart()))
            {
               result.setStatus(Status.FAILED);
               result.setThrowable(
                     new PerformanceException("The test didnt finish within the specified time: "
                           +performance.time()+"ms, it took "+(result.getEnd()-result.getStart())+"ms."));
            }
           
            // fetch suiteResult, get the correct classResult and append the test to that
            // classResult.
            PerformanceSuiteResult suiteResult = suiteResultInst.get();
            if(suiteResult != null)
               suiteResult.getResult(event.getTestClass().getName()).addMethodResult(
                     new PerformanceMethodResult(
                           performance.time(),
                           (result.getEnd()-result.getStart()),
                           event.getTestMethod()));
            else
               System.out.println("PerformanceVerifier didnt get PerformanceSuiteResult!");
         }
View Full Code Here

Examples of org.wikipediacleaner.utils.Performance

   */
  public static List<CheckErrorPage> analyzeErrors(
      Collection<CheckErrorAlgorithm> algorithms,
      PageAnalysis pageAnalysis,
      boolean onlyAutomatic) {
    Performance perf = new Performance("CheckError.analyzeErrors");
    if (traceTime) {
      perf.printStart();
    }
    List<CheckErrorPage> errorsFound = new ArrayList<CheckErrorPage>();
    if ((algorithms != null) &&
        (pageAnalysis != null) &&
        (pageAnalysis.getContents() != null)) {
      for (CheckErrorAlgorithm algorithm : algorithms) {
        if ((algorithm != null) &&
            (algorithm.isAvailable()) &&
            (CWConfigurationError.isPriorityActive(algorithm.getPriority()))) {
          List<CheckErrorResult> results = new ArrayList<CheckErrorResult>();
          boolean errorFound = false;
          int errorNumber = algorithm.getErrorNumber();
          PageAnalysis.Result result = pageAnalysis.getCheckWikiErrors(errorNumber);
          if (result != null) {
            errorFound = result.getErrors(results);
          } else {
            errorFound = algorithm.analyze(pageAnalysis, results, onlyAutomatic);
            pageAnalysis.setCheckWikiErrors(errorNumber, errorFound, results);
          }
          if (errorFound) {
            CheckErrorPage errorPage = new CheckErrorPage(pageAnalysis.getPage(), algorithm);
            errorPage.setResults(true, results);
            errorsFound.add(errorPage);
          }
          if (traceTime) {
            String message =
                "Error n°" + algorithm.getErrorNumber() +
                ", " + errorFound +
                ", " + results.size() + " occurrences";
            perf.printStep(message);
          }
        }
      }
    }
    if (traceTime) {
      perf.printEnd();
    }
    return errorsFound;
  }
View Full Code Here

Examples of org.wikipediacleaner.utils.Performance

  public static CheckErrorPage analyzeError(
      CheckErrorAlgorithm algorithm, PageAnalysis pageAnalysis) {
    if ((algorithm == null) || (pageAnalysis == null)) {
      return null;
    }
    Performance perf = new Performance("CheckError.analyzeError");
    CheckErrorPage errorPage = new CheckErrorPage(pageAnalysis.getPage(), algorithm);
    boolean errorFound = false;
    List<CheckErrorResult> errorsFound = new ArrayList<CheckErrorResult>();
    int errorNumber = algorithm.getErrorNumber();
    PageAnalysis.Result result = pageAnalysis.getCheckWikiErrors(errorNumber);
    if (result != null) {
      errorFound = result.getErrors(errorsFound);
    } else {
      errorFound = algorithm.analyze(pageAnalysis, errorsFound, false);
      pageAnalysis.setCheckWikiErrors(errorNumber, errorFound, errorsFound);
    }
    errorPage.setResults(errorFound, errorsFound);
    if (traceTime) {
      perf.printStep("Error n°" + algorithm.getErrorNumber());
    }
    return errorPage;
  }
View Full Code Here

Examples of org.wikipediacleaner.utils.Performance

    Iterator<Suggestion> itSuggestion = suggestions.iterator();
    List<Replacement> tmpReplacements = new ArrayList<CheckErrorAlgorithm501.Replacement>();
    while (itSuggestion.hasNext()) {
      Suggestion suggestion = itSuggestion.next();
      if (!suggestion.isOtherPattern()) {
        Performance perf = new Performance("Slow regular expression");
        perf.setThreshold(slowRegexp);
        itSuggestion.remove();
        Matcher matcher = suggestion.initMatcher(contents);
        for (ContentsChunk chunk : chunks) {
          matcher.region(chunk.getBegin(), chunk.getEnd());
          int authorizedBegin = chunk.getBegin();
          while (matcher.find()) {
            int begin = matcher.start();
            int end = matcher.end();
            boolean shouldKeep = true;
            if (shouldKeep && (begin > 0) &&
                (Character.isLetterOrDigit(contents.charAt(begin))) &&
                (Character.isLetterOrDigit(contents.charAt(begin - 1)))) {
              shouldKeep = false;
            }
            if (shouldKeep && (end < contents.length()) &&
                (Character.isLetterOrDigit(contents.charAt(end))) &&
                (Character.isLetterOrDigit(contents.charAt(end - 1)))) {
              shouldKeep = false;
            }
            if (shouldKeep) {
              tmpReplacements.clear();
              shouldKeep = addReplacements(
                  begin, end, contents, authorizedBegin, chunk.getEnd(),
                  suggestion, tmpReplacements);
            }
            if (shouldKeep && (analysis.getAreas().getEndArea(begin) > begin)) {
              shouldKeep = false;
            }
            if (shouldKeep && (analysis.isInTemplate(begin) != null)) {
              shouldKeep = false;
            }
            if (shouldKeep) {
              shouldKeep = shouldKeep(contents, begin, end);
            }
            if (shouldKeep) {
              result = true;
              replacements.addAll(tmpReplacements);
            }
            authorizedBegin = end;
          }
        }
        perf.printEnd(suggestion.getPatternText());
      }
    }

    return result;
  }
View Full Code Here

Examples of org.wikipediacleaner.utils.Performance

    Iterator<Suggestion> itSuggestion = suggestions.iterator();
    List<Replacement> tmpReplacements = new ArrayList<CheckErrorAlgorithm501.Replacement>();
    while (itSuggestion.hasNext()) {
      Suggestion suggestion = itSuggestion.next();
      if (suggestion.isOtherPattern()) {
        Performance perf = new Performance("Slow regular expression");
        perf.setThreshold(slowRegexp);
        itSuggestion.remove();
        Matcher matcher = suggestion.initMatcher(contents);
        for (ContentsChunk chunk : chunks) {
          matcher.region(chunk.getBegin(), chunk.getEnd());
          int authorizedBegin = chunk.getBegin();
          while (matcher.find()) {
            int begin = matcher.start();
            int end = matcher.end();
            tmpReplacements.clear();
            boolean shouldKeep = addReplacements(
                begin, end, contents, authorizedBegin, chunk.getEnd(),
                suggestion, tmpReplacements);
            if (shouldKeep) {
              shouldKeep = shouldKeep(contents, begin, end);
            }
            if (shouldKeep) {
              result = true;
              replacements.addAll(tmpReplacements);
            }
            authorizedBegin = end;
          }
        }
        perf.printEnd(suggestion.getComment(), suggestion.getPatternText());
      }
    }

    return result;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.