Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ output/current/idleWithBrowser/**
output/current/withGhostery/**
output/current/withoutGhostery/**
output/time/withGhostery/**
output/time/withoutGhostery/**
output/time/withoutExtensions/**
output/time/withUBlockOrigin/**
profiles/withGhostery/**
profiles/withoutGhostery/**
profiles/withoutExtensions/**
profiles/withUBlockOrigin/**

# Do not ignore a special file name
!.gitkeep
53 changes: 42 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ npm start
Usage:

```
--US site list for US region
--EU site list for European region
--firefox select Firefox browser
--chrome select Chrome browser
--with-ghostery load Ghostery extension
--US site list for US region
--EU site list for European region
--firefox select Firefox browser
--chrome select Chrome browser
--with-ghostery load Ghostery extension
--with-uBO load uBlock Origin extension
--delete-profiles-folders delete browser profile folders to make a clear run
--delete-output-folders delete output folders to make a clear run
```

Example output:

```
LOG: Addon temp path:
LOG: Downloading addon
Expand All @@ -40,19 +44,48 @@ LOG={"index":360,"url":"https://www.virgilio.it/","loadTime":1433,"loadedAt":"20

```

## How to show the results?

The results are shown in the form of a graph and two tables.

The graph shows the ratio of average pages opening time for the scenarios indicated.
The first table contains the results of the web pages load time measurements for different browser configurations and installed extensions.
The second table shows the total time taken to load web pages for different browser configurations and installed extensions, expressed in seconds.

These scenarios are:

1. How much faster is Chrome without Ghostery than Firefox without Ghostery?
2. How much faster is Chrome with Ghostery than Firefox with Ghostery?
3. How much faster is Firefox with Ghostery than without Ghostery?
4. How much faster is Chrome with Ghostery than without Ghostery?
5. How much faster is Firefox with Ghostery than with uBlock Origin?
6. How much faster is Chrome with Ghostery than with uBlock Origin?

Firstly, download the output/timing measurements. Secondly, a simple server needs to be started. The script will load these measurements and calculate the average page opening time and calculate the total page loading time. To run the server:

```
node www/server.js
```

In any browser, open the following address:
http://localhost:3000/index.html

Example output:

![Compare load times](compareLoadTimeGraphTwoTables.png)

## Convert the current to power based on the measurements taken from the benchmark

To measure AC current, Gravity Analog AC Current Sensor was used. All the code to gather current value is available on https://wiki.dfrobot.com/Gravity_Analog_AC_Current_Sensor__SKU_SEN0211_


Start calculate

```
npm run -- currentToPower
```


Example input:

```
10:11:50.121 0.091
10:11:50.121 0.112
Expand All @@ -63,8 +96,8 @@ Example input:
10:11:50.152 0.095
```


Example output:

```
[
{
Expand Down Expand Up @@ -97,9 +130,6 @@ Example output:
]
```




## Based on the collected data from the benchmark, calculate the average time to load URLs

Start read time
Expand All @@ -116,6 +146,7 @@ Usage:
```

Example output:

```
With Ghostery
Average urls load time:
Expand Down
Binary file added compareLoadTimeGraphTwoTables.png
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If Firefox takes 1,162,466.08 sec and Chrome 988,810.84, you have "117.56% faster". Looking at the number, I assume you mean 17.56% faster (or a speedup of 1.1756).

1162466.08 / 988810.84 = 1.1756 (so it is 17.56% faster or 1.1756 times faster)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, in such graphs, I find it always helpful to say either "Fewer is better" or "More is better".

For instance here: "Total Load Time Ratio, More is better"

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
135 changes: 97 additions & 38 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,77 @@ import { Builder, Browser, By, until } from 'selenium-webdriver';
import firefox from 'selenium-webdriver/firefox.js';
import chrome from 'selenium-webdriver/chrome.js';
import fs from 'fs';
import { downloadAddon, sleep, switchToWindowWithUrl } from './src/helpers.js';
import {
downloadAddon,
sleep,
switchToWindowWithUrl,
createFolders,
deleteFolders,
} from './src/helpers.js';
import { directoriesOutput, directoriesProfiles } from './src/directories.js';

const timestamp = new Date().toISOString();
const isRegionEU = Boolean(process.argv.find((arg) => arg === '--EU'));
const isRegionUS = Boolean(process.argv.find((arg) => arg === '--US'));
const isChromeSelected = Boolean(
process.argv.find((arg) => arg === '--chrome'),
const deleteProfilesFolders = Boolean(
process.argv.find((arg) => arg === '--delete-profiles-folders'),
);
const isFirefoxSelected = Boolean(
process.argv.find((arg) => arg === '--firefox'),
);
const isGhosteryEnabled = Boolean(
process.argv.find((arg) => arg === '--with-ghostery'),
const deleteOutputsFolders = Boolean(
process.argv.find((arg) => arg === '--delete-output-folders'),
);
let selectedBrowser = {
isChrome: Boolean(process.argv.find((arg) => arg === '--chrome')),
isFirefox: Boolean(process.argv.find((arg) => arg === '--firefox')),
};
let selectedExtension = {
isGhostery: Boolean(process.argv.find((arg) => arg === '--with-ghostery')),
isUBlockOrigin: Boolean(process.argv.find((arg) => arg === '--with-uBO')),
};

if (deleteProfilesFolders) {
deleteFolders(directoriesProfiles);
}
if (deleteOutputsFolders) {
deleteFolders(directoriesOutput);
}
createFolders(directoriesOutput);
createFolders(directoriesProfiles);

const extensionUrls = {
Firefox: {
Ghostery:
'https://github.com/ghostery/ghostery-extension/releases/download/v10.2.10/ghostery-firefox.zip',
UBlockOrigin:
'https://github.com/gorhill/uBlock/releases/download/1.56.0/uBlock0_1.56.0.firefox.signed.xpi',
},
Chrome: {
Ghostery:
'https://github.com/ghostery/ghostery-extension/releases/download/v10.2.10/ghostery-chrome.zip',
UBlockOrigin:
'https://github.com/gorhill/uBlock/releases/download/1.56.0/uBlock0_1.56.0.chromium.zip',
},
};

const browser = selectedBrowser.isFirefox ? 'Firefox' : 'Chrome';
let extensionUrl;

if (selectedExtension.isGhostery) {
extensionUrl = extensionUrls[browser]['Ghostery'];
} else if (selectedExtension.isUBlockOrigin) {
extensionUrl = extensionUrls[browser]['UBlockOrigin'];
}

const config = isFirefoxSelected
const config = selectedBrowser.isFirefox
? {
browser: 'Firefox',
browser: browser,
addonUUID: 'd56a5b99-51b6-4e83-ab23-796216679614',
extensionUrl:
'https://github.com/ghostery/ghostery-extension/releases/download/v10.2.10/ghostery-firefox.zip',
extensionUrl: extensionUrl,
addonBaseUrl: `moz-extension://d56a5b99-51b6-4e83-ab23-796216679614`,
}
: {
browser: 'Chrome',
browser: browser,
addonUUID: null,
extensionUrl:
'https://github.com/ghostery/ghostery-extension/releases/download/v10.2.10/ghostery-chrome.zip',
extensionUrl: extensionUrl,
addonBaseUrl: null, //get from runtime
};

Expand All @@ -51,51 +94,66 @@ const urls = fs

let outputPath = 'output/time';
let driver;
const addon = await downloadAddon(config.extensionUrl);
const addon = await downloadAddon(config.extensionUrl, selectedExtension);

let profileOutputPath = '';
if (selectedExtension.isGhostery) {
profileOutputPath = `profiles/withGhostery/${config.browser}`;
} else if (selectedExtension.isUBlockOrigin) {
profileOutputPath = `profiles/withUBlockOrigin/${config.browser}`;
} else {
profileOutputPath = `profiles/withoutExtensions/${config.browser}`;
}

if (isChromeSelected) {
if (selectedBrowser.isChrome) {
const options = new chrome.Options();
options.addArguments('--profile-directory=Default');
if (isGhosteryEnabled) {
if (selectedExtension.isGhostery) {
console.log(`LOG: Installing addon for ${config.browser}.`);
options.addArguments(
`--user-data-dir=profiles/withGhostery/${config.browser}`,
);
options.addArguments(`--user-data-dir=${profileOutputPath}`);
outputPath += `/withGhostery/${config.browser}`;
options.addArguments(`--load-extension=${addon}`);
} else if (selectedExtension.isUBlockOrigin) {
console.log(`LOG: Installing addon for ${config.browser}.`);
options.addArguments(`--user-data-dir=${profileOutputPath}`);
outputPath += `/withUBlockOrigin/${config.browser}`;
options.addArguments(`--load-extension=${addon}/uBlock0.chromium`);
} else {
options.addArguments(
`--user-data-dir=profiles/withoutGhostery/${config.browser}`,
);
outputPath += `/withoutGhostery/${config.browser}`;
options.addArguments(`--user-data-dir=${profileOutputPath}`);
outputPath += `/withoutExtensions/${config.browser}`;
}
driver = await new Builder()
.forBrowser(Browser.CHROME)
.setChromeOptions(options)
.build();
} else if (isFirefoxSelected) {
} else if (selectedBrowser.isFirefox) {
const options = new firefox.Options();
options.setPreference(
'extensions.webextensions.uuids',
`{"firefox@ghostery.com": "${config.addonUUID}"}`,
);
// options.addArguments("--headless");
if (isGhosteryEnabled) {
if (selectedExtension.isGhostery) {
options.addArguments('-profile', `profiles/withGhostery/${config.browser}`);
outputPath += `/withGhostery/${config.browser}`;
} else if (selectedExtension.isUBlockOrigin) {
options.addArguments(
'-profile',
`profiles/withUBlockOrigin/${config.browser}`,
);
outputPath += `/withUBlockOrigin/${config.browser}`;
} else {
options.addArguments(
'-profile',
`profiles/withoutGhostery/${config.browser}`,
`profiles/withoutExtensions/${config.browser}`,
);
outputPath += `/withoutGhostery/${config.browser}`;
outputPath += `/withoutExtensions/${config.browser}`;
}
driver = await new Builder()
.forBrowser(Browser.FIREFOX)
.setFirefoxOptions(options)
.build();

if (isGhosteryEnabled) {
if (selectedExtension.isGhostery || selectedExtension.isUBlockOrigin) {
console.log(`LOG: Installing addon for ${config.browser}.`);
await driver.installAddon(addon, true);
}
Expand Down Expand Up @@ -151,14 +209,14 @@ const logPageLoadTime = async (n, url, now) => {
};

try {
if (isGhosteryEnabled) {
if (selectedExtension.isGhostery) {
if (!fs.existsSync(`profiles/withGhostery/${config.browser}/onboarded`)) {
await driver.wait(
async () => (await driver.getAllWindowHandles()).length === 2,
);
console.info('INFO: Ghostery onboarding opened.');

if (isChromeSelected) {
if (selectedBrowser.isChrome) {
let handles = await driver.getAllWindowHandles();
await driver.switchTo().window(handles[1]);
config.addonBaseUrl = (await driver.getCurrentUrl()).split('/pages')[0];
Expand Down Expand Up @@ -201,15 +259,16 @@ try {
}

fs.writeFileSync(`profiles/withGhostery/${config.browser}/onboarded`, '');
}

console.info(`INFO: Open websites from for region: ${region}.`);

if (isGhosteryEnabled) {
// Wait for Ghostery extension to download fresh Ad-blocking filters
await sleep(1000 * 20);
console.info('INFO: Ghostery - Privacy Ad Blocker was installed.');
} else if (selectedExtension.isUBlockOrigin) {
console.info('INFO: uBlock Origin was installed.');
}

console.info(`INFO: Open websites from for region: ${region}.`);

await driver.executeScript('window.open()', '');
const handle = await driver.getAllWindowHandles();
await driver.switchTo().window(handle[0]);
Expand All @@ -223,7 +282,7 @@ try {
}

if (
isChromeSelected &&
selectedBrowser.isChrome &&
fs.existsSync(`profiles/withGhostery/${config.browser}/onboarded`)
) {
fs.unlinkSync(`profiles/withGhostery/${config.browser}/onboarded`);
Expand Down
Empty file.
Empty file.
Empty file.
Empty file removed output/time/withGhostery/.gitkeep
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Loading