Skip to content

Commit 926cd85

Browse files
committed
Updated README and Selenium test driver
1 parent b1ea915 commit 926cd85

File tree

2 files changed

+52
-55
lines changed

2 files changed

+52
-55
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ open a new shell in the tests directory
6666

6767
Open [http://localhost:8080/tests/chart.html](http://localhost:8080/tests/chart.html) for the results
6868

69-
A test showing the durations on my machine can be seen [here](https://rawgit.com/krausest/js-framework-benchmark/master/tests/chart.html)
69+
A test showing the durations on my machine can be seen [here](https://rawgit.com/krausest/js-framework-benchmark/master/webdriver-java/chart.html)

webdriver-java/src/main/java/net/stefankrause/App.java

Lines changed: 51 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,50 @@
2525

2626
public class App {
2727

28-
public final static int REPEAT_RUN = 5;
28+
public static final int WARMUP_COUNT = 5;
29+
private final static int REPEAT_RUN = 5;
30+
private final static String frameworks[] = {"angular", "angular2","aurelia", "ember/dist", "mithril", "ractive", "react", "vidom", "vue"};
31+
private final static Bench[] benches = new Bench[] {new BenchRun(), new BenchRunHot(), new BenchUpdate(), new BenchSelect(), new BenchRemove()};
32+
33+
private static class PLogEntry {
34+
private final String name;
35+
private final long ts;
36+
private final long duration;
37+
private final String message;
38+
39+
public PLogEntry(String name, long ts, long duration, String message) {
40+
this.name = name;
41+
this.ts = ts;
42+
this.duration = duration;
43+
this.message = message;
44+
}
45+
46+
public String getName() {
47+
return name;
48+
}
49+
50+
public long getTs() {
51+
return ts;
52+
}
53+
54+
public long getDuration() {
55+
return duration;
56+
}
57+
58+
public String getMessage() {
59+
return message;
60+
}
61+
62+
@Override
63+
public String toString() {
64+
return "PLogEntry{" +
65+
"name='" + name + '\'' +
66+
", ts=" + ts +
67+
", duration=" + duration +
68+
", message='" + message + '\'' +
69+
'}';
70+
}
71+
}
2972

3073
public interface Bench {
3174
void init(WebDriver driver, String framework);
@@ -55,7 +98,7 @@ public void init(WebDriver driver, String framework) {
5598
driver.get("localhost:8080/" + framework + "/");
5699
WebDriverWait wait = new WebDriverWait(driver, 10);
57100
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("run")));
58-
for (int i=0;i<5;i++) {
101+
for (int i = 0; i< WARMUP_COUNT; i++) {
59102
driver.findElement(By.id("run")).click();
60103
element = wait.until(ExpectedConditions.elementToBeClickable(By.id("run")));
61104
}
@@ -77,7 +120,7 @@ public void init(WebDriver driver, String framework) {
77120
WebDriverWait wait = new WebDriverWait(driver, 10);
78121
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("run")));
79122
element.click();
80-
for (int i=0;i<5;i++) {
123+
for (int i = 0; i< WARMUP_COUNT; i++) {
81124
driver.findElement(By.id("update")).click();
82125
element = wait.until(ExpectedConditions.elementToBeClickable(By.id("update")));
83126
}
@@ -98,7 +141,7 @@ public void init(WebDriver driver, String framework) {
98141
WebDriverWait wait = new WebDriverWait(driver, 10);
99142
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("run")));
100143
element.click();
101-
for (int i=0;i<5;i++) {
144+
for (int i = 0; i< WARMUP_COUNT; i++) {
102145
element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//tbody/tr["+(i+1)+"]/td[2]/a")));
103146
element.click();
104147
}
@@ -120,7 +163,7 @@ public void init(WebDriver driver, String framework) {
120163
WebDriverWait wait = new WebDriverWait(driver, 10);
121164
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("run")));
122165
element.click();
123-
for (int i=8;i>=3;i--) {
166+
for (int i=3+WARMUP_COUNT;i>=3;i--) {
124167
element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//tbody/tr["+i+"]/td[3]/a")));
125168
element.click();
126169
}
@@ -140,9 +183,6 @@ private void runTests() throws Exception {
140183

141184
DesiredCapabilities cap = setUp();
142185

143-
144-
String frameworks[] = {"angular", "angular2","aurelia", "ember/dist", "mithril", "ractive", "react", "vidom", "vue"};
145-
Bench[] benches = new Bench[] {new BenchRun(), new BenchRunHot(), new BenchUpdate(), new BenchSelect(), new BenchRemove()};
146186
int length = REPEAT_RUN;
147187
Table<String, String, DoubleSummaryStatistics> results = HashBasedTable.create();
148188

@@ -230,7 +270,7 @@ public DesiredCapabilities setUp() throws Exception {
230270
logPrefs.enable(LogType.BROWSER, Level.ALL);
231271
cap.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
232272

233-
Map<String, Object> perfLogPrefs = new HashMap<String, Object>();
273+
Map<String, Object> perfLogPrefs = new HashMap<>();
234274
perfLogPrefs.put("traceCategories", "browser,devtools.timeline,devtools"); // comma-separated trace categories
235275
ChromeOptions options = new ChromeOptions();
236276
options.setExperimentalOption("perfLoggingPrefs", perfLogPrefs);
@@ -295,13 +335,12 @@ Double printLog(WebDriver driver, boolean print, boolean isAurelia) throws Excep
295335
// First TimerFire
296336
Optional<PLogEntry> evtTimer = filtered.stream().filter(pe -> "TimerFire".equals(pe.getName())).filter(pe -> pe.ts > tsEvent).findFirst();
297337
long tsEventFire = evtTimer.map(pe -> pe.ts).orElse(0L);
298-
// First Paint afer TimerFire
338+
// First Paint after TimerFire only for Aurelia
299339
long tsAfter = isAurelia ? tsEventFire : tsEvent;
300340
Optional<PLogEntry> lastPaint = filtered.stream().filter(pe -> "Paint".equals(pe.getName())).
301341
filter(pe -> pe.ts > tsAfter).findFirst();
302-
// Optional<PLogEntry> lastPaint = filtered.stream().filter(pe -> "Paint".equals(pe.getName())).reduce((a, b) -> b);
303342

304-
if (print) System.out.println("************************ filtered");
343+
if (print) System.out.println("************************ filtered events");
305344
filtered.forEach(e -> System.out.println(e));
306345
if (evt.isPresent() && lastPaint.isPresent()) {
307346
if (print) System.out.println("Duration "+(lastPaint.get().ts + lastPaint.get().duration - evt.get().ts)/1000.0);
@@ -311,46 +350,6 @@ Double printLog(WebDriver driver, boolean print, boolean isAurelia) throws Excep
311350

312351
}
313352

314-
private static class PLogEntry {
315-
private final String name;
316-
private final long ts;
317-
private final long duration;
318-
private final String message;
319-
320-
public PLogEntry(String name, long ts, long duration, String message) {
321-
this.name = name;
322-
this.ts = ts;
323-
this.duration = duration;
324-
this.message = message;
325-
}
326-
327-
public String getName() {
328-
return name;
329-
}
330-
331-
public long getTs() {
332-
return ts;
333-
}
334-
335-
public long getDuration() {
336-
return duration;
337-
}
338-
339-
public String getMessage() {
340-
return message;
341-
}
342-
343-
@Override
344-
public String toString() {
345-
return "PLogEntry{" +
346-
"name='" + name + '\'' +
347-
", ts=" + ts +
348-
", duration=" + duration +
349-
", message='" + message + '\'' +
350-
'}';
351-
}
352-
}
353-
354353
List<PLogEntry> submitPerformanceResult(List<LogEntry> perfLogEntries, boolean print)
355354
throws IOException, JSONException {
356355
ArrayList<PLogEntry> filtered = new ArrayList<>();
@@ -368,9 +367,7 @@ List<PLogEntry> submitPerformanceResult(List<LogEntry> perfLogEntries, boolean p
368367
(long)getAsLong(obj, "message.params.ts"),
369368
(long)getAsLong(obj, "message.params.dur"),
370369
entry.getMessage()));
371-
;
372370
}
373-
// System.out.println(entry);
374371
}
375372

376373
return filtered;

0 commit comments

Comments
 (0)