public static void foreignDisasters(WebDriver driver, String page) throws InterruptedException { String section = "Foreign Disasters"; String[] foreignDisasterContainer = { "xpath", "//*[@id=\"block-views-static-view-pages-block-8\"]/div/div/div/ul/li[1]/div/div[1]/div/div/p/strong", "Foreign Disaster Information" }; String[] foreignCrisis = { "xpath", "//*[@id=\"block-views-static-view-pages-block-8\"]/div/div/div/ul/li[1]/div/div[3]/div/div", "Are You Caught in a Foreign Crisis?" }; String[] familyAbroad = { "xpath", "//*[@id=\"block-views-static-view-pages-block-8\"]/div/div/div/ul/li[2]/div/div[2]/div/div", "Are You Concerned About Family Abroad?" }; String[] terroristAttack = { "xpath", "//*[@id=\"block-views-static-view-pages-block-8\"]/div/div/div/ul/li[3]/div/div[2]/div/div/p", "Were You Affected by a Terrorist Attack Abroad?" }; String[] disasterResponse = { "xpath", "//*[@id=\"block-views-static-view-pages-block-8\"]/div/div/div/ul/li[4]/div/div[2]/div/div/p", "Do You Want to Help Support Disaster Response Abroad?" }; String[][] myArray = { foreignDisasterContainer, foreignCrisis, familyAbroad, terroristAttack, disasterResponse }; RunTest.runTest(myArray, driver, section, page); }
public static void main(String[] args) { Logger log = Logger.getLogger(Main01e3.class); log.info("1.3) GAUSS TEST"); for (int k = 1; k < 8; k++) { for (int n = 0; n < 21; n++) { int num = 5 + n * 10; RunTest e = new RunTest(num, k); e.addKlass(1, 1, 1); e.addKlass(2, 2, 2); System.out.println(k + "\t" + num + "\t" + e.runTests(10000)); } System.out.println(); } }
public static void accessibility(WebDriver driver, String page) throws InterruptedException { String section = "Body"; String[] accessibilityContacts = { "xpath", "//*[@id=\"content-container\"]/article/div/div/div", "Accessibility Contacts" }; String[] backgroundImage = {"id", "background-image-container", "Background Image"}; String[][] myArray = {accessibilityContacts, backgroundImage}; RunTest.runTest(myArray, driver, page, section); }
/** * Timing and report (to standard output) the average time and standard deviation of a single * call. The timing is performed by calling the {@link #time(int,int,boolean,Callable[]) time} * method. * * @param title Title of the test (for the report). * @param repeatChunk Each timing measurement will done done for that number of repeats of the * code. * @param repeatStat Timing will be averaged over that number of runs. * @param runGC Call {@code System.gc()} between each timed block. When set to {@code true}, the * test will run much slower. * @param methods Codes being timed. * @return for each of the given {@code methods}, a statistics of the average times (in * milliseconds) taken by a single call to the {@code call} method (i.e. the time taken by * each timed block divided by {@code repeatChunk}). */ public static StatisticalSummary[] timeAndReport( String title, int repeatChunk, int repeatStat, boolean runGC, RunTest... methods) { // Header format. final String hFormat = "%s (calls per timed block: %d, timed blocks: %d, time unit: ms)"; // Width of the longest name. int nameLength = 0; for (RunTest m : methods) { int len = m.getName().length(); if (len > nameLength) { nameLength = len; } } final String nameLengthFormat = "%" + nameLength + "s"; // Column format. final String cFormat = nameLengthFormat + " %14s %14s %10s %10s %15s"; // Result format. final String format = nameLengthFormat + " %.8e %.8e %.4e %.4e % .8e"; System.out.println(String.format(hFormat, title, repeatChunk, repeatStat)); System.out.println( String.format( cFormat, "name", "time/call", "std error", "total time", "ratio", "difference")); final StatisticalSummary[] time = time(repeatChunk, repeatStat, runGC, methods); final double refSum = time[0].getSum() * repeatChunk; for (int i = 0, max = time.length; i < max; i++) { final StatisticalSummary s = time[i]; final double sum = s.getSum() * repeatChunk; System.out.println( String.format( format, methods[i].getName(), s.getMean(), s.getStandardDeviation(), sum, sum / refSum, sum - refSum)); } return time; }
public static void run(WebDriver driver) throws InterruptedException { // System.out.println("Running test for Foreign Disasters"); driver.get("http://www.disasterassistance.gov/information/foreign-disasters"); Header.run(driver, page); foreignDisasters(driver, page); SendEmail.run(driver); Footer.run(driver, page); RunTest.translate(driver); String spanishPage = page + " - Spanish"; Header.run(driver, spanishPage); foreignDisasters(driver, spanishPage); SendEmail.run(driver); Footer.run(driver, spanishPage); driver.get("http://www.disasterassistance.gov/"); }
public static void run(WebDriver driver) throws InterruptedException, MessagingException, IOException { // System.out.println("Running test for Accessibility"); driver.get("http://www.disasterassistance.gov/help/accessibility"); Header.run(driver, page); accessibility(driver, page); SendEmail.run(driver); Footer.run(driver, page); RunTest.translate(driver); String spanishPage = page + " - Spanish"; Header.run(driver, spanishPage); accessibility(driver, spanishPage); SendEmail.run(driver); Footer.run(driver, spanishPage); driver.get("http://www.disasterassistance.gov/"); }
private static void runTest0( int testSkip, boolean startAtZero, String testName, String with, RunTest runTest) throws InterruptedException { if (with.length() > 0) { with = " with " + with; } boolean skipBigClasses = with.contains("BCEL and computeFrames"); int totalCount = 0; long totalSize = 0; long totalTime = 0; System.out.println("\nStarting " + testName + with + " test."); for (int i = 0; i < repeats; ++i) { runTest.init(); long t = System.currentTimeMillis(); int count = 0; long size = 0; int[] errors = {0}; long longest = 0; int longestSize = 0; int skipped = 0; for (int j = startAtZero ? 0 : i; j < classes.size(); j += testSkip) { count++; byte[] b = classes.get(j); if (skipBigClasses && b.length > 16 * 1024) { skipped++; continue; } size += b.length; try { long start = System.currentTimeMillis(); runTest.test(b, errors); long end = System.currentTimeMillis(); long time = end - start; if (longest < time) { longest = time; longestSize = b.length; } if (time > MAX_ITERATION_SEC * 1000 / 10) { System.out.println( "--- time to " + testName + " the class " + classNames.get(j) + with + " took " + time + " ms. bytes=" + b.length); } if (end - t > MAX_ITERATION_SEC * 1000) { // System.out.println("Stopping iteration due to a // longer run time."); break; } } catch (Exception ignored) { errors[0]++; } catch (Throwable e) { System.err.println(classNames.get(j) + ": " + e); errors[0]++; } } t = System.currentTimeMillis() - t; String errorStr = errors[0] > 0 ? " (" + errors[0] + " errors)" : ""; String skippedStr = skipped == 0 ? "" : " (" + skipped + " skipped as BCEL/computeFrames on >16K classes is very slow)"; String longestStr = ""; if (longest > 50) { longestStr = " the longest took " + longest + " ms (" + longestSize + " bytes)"; } if (i > 0) { System.out.println( "- to " + testName + ' ' + count + " classes" + with + " = " + t + " ms" + errorStr + longestStr + skippedStr + '.'); totalCount += count; totalSize += size; totalTime += t; } } System.out.println( "Time to " + testName + ' ' + totalCount + " classes" + with + " = " + totalTime + " ms.\n" + "Processing rate = " + totalCount * 1000 / totalTime + " classes per sec (" + totalSize * 1000 / totalTime / 1024 + " kB per sec)."); System.gc(); Thread.sleep(2500); }