Skip to content

Commit be49edd

Browse files
committed
benches): add concurrent logs
1 parent d9ce54c commit be49edd

15 files changed

+299
-14
lines changed

.github/workflows/benches.yml

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ jobs:
5858
git config --global user.name "GitHub Actions"
5959
git config --global user.email "actions@github.com"
6060
git add benches/logs/
61+
git add benches/logs_concurrent/
6162
git commit -m "Update benchmark logs" || echo "No changes to commit"
6263
git push
6364
env:

benches/.dockerignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
logs
1+
logs
2+
logs_concurrent

benches/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,24 @@ The `Argless` has the headless instance launched with minimal args required to r
6161

6262
### Mac
6363

64+
Sync 10x
65+
6466
* [Darwin_v10cpu](./logs/Darwin_v10cpu_benchmark_logs.txt)
6567
* [Darwin_v10cpu Argless](./logs/Darwin_v10cpu_benchmark_noargs_logs.txt)
6668

69+
Concurrent 10x
70+
71+
* [Darwin_v10cpu](./logs_concurrent/Darwin_v10cpu_benchmark_logs.txt)
72+
* [Darwin_v10cpu Argless](./logs_concurrent/Darwin_v10cpu_benchmark_noargs_logs.txt)
73+
6774
### Linux
6875

76+
Sync 10x
77+
6978
* [Linux_v4cpu](./logs/Linux_v4cpu_benchmark_logs.txt)
7079
* [Linux_v4cpu Argless](./logs/Linux_v4cpu_benchmark_noargs_logs.txt)
80+
81+
Concurrent 10x
82+
83+
* [Linux_v4cpu](./logs_concurrent/Linux_v4cpu_benchmark_logs.txt)
84+
* [Linux_v4cpu Argless](./logs_concurrent/Linux_v4cpu_benchmark_noargs_logs.txt)

benches/basic.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
pub mod run;
1+
mod run;
2+
mod run_concurrent;
3+
24
use std::env::set_var;
35

46
const LOG_FILE_NAME: &str = "benchmark_logs.txt";
57

68
#[tokio::main]
79
async fn main() {
810
set_var("CHROME_INIT", "ignore"); // Ignore the auto start.
9-
run::run(LOG_FILE_NAME).await
11+
set_var("HOSTNAME", "localhost");
12+
headless_browser_lib::fork(Some(*headless_browser_lib::conf::DEFAULT_PORT)).await;
13+
let task = tokio::spawn(headless_browser_lib::run_main());
14+
tokio::time::sleep(std::time::Duration::from_millis(1000)).await; // Wait for the server to load.
15+
run::run(LOG_FILE_NAME).await;
16+
run_concurrent::run(LOG_FILE_NAME).await;
17+
headless_browser_lib::shutdown_instances().await;
18+
task.abort();
1019
}

benches/basic_no_args.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
pub mod run;
1+
mod run;
2+
mod run_concurrent;
23
use std::env::set_var;
34

45
const LOG_FILE_NAME: &str = "benchmark_noargs_logs.txt";
@@ -7,5 +8,12 @@ const LOG_FILE_NAME: &str = "benchmark_noargs_logs.txt";
78
async fn main() {
89
set_var("CHROME_INIT", "ignore"); // Ignore the auto start.
910
set_var("TEST_NO_ARGS", "true");
10-
run::run(LOG_FILE_NAME).await
11+
set_var("HOSTNAME", "localhost");
12+
headless_browser_lib::fork(Some(*headless_browser_lib::conf::DEFAULT_PORT)).await;
13+
let task = tokio::spawn(headless_browser_lib::run_main());
14+
tokio::time::sleep(std::time::Duration::from_millis(1000)).await; // Wait for the server to load.
15+
run::run(LOG_FILE_NAME).await;
16+
run_concurrent::run(LOG_FILE_NAME).await;
17+
headless_browser_lib::shutdown_instances().await;
18+
task.abort();
1119
}

benches/logs/Darwin_v10cpu_benchmark_logs.txt

+16
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,19 @@ MACHINE: Darwin/v10cpu
55
DATE: 2025-02-25 09:49:12
66
Average Duration: 154.52907ms
77

8+
<http://spider.cloud> - 10 SAMPLES
9+
CHROME_PATH: headless_shell
10+
CHROME_ARGS: (92)("--remote-debugging-address=0.0.0.0,--remote-debugging-port=9223,--headless,--disable-gpu,--disable-gpu-sandbox,--use-gl=angle,--no-first-run,--no-sandbox,--disable-setuid-sandbox,--no-zygote,--hide-scrollbars,--user-data-dir=~/.config/google-chrome,--allow-running-insecure-content,--autoplay-policy=user-gesture-required,--ignore-certificate-errors,--no-default-browser-check,--disable-dev-shm-usage,--disable-threaded-scrolling,--disable-cookie-encryption,--disable-demo-mode,--disable-dinosaur-easter-egg,--disable-fetching-hints-at-navigation-start,--disable-site-isolation-trials,--disable-web-security,--disable-threaded-animation,--disable-sync,--disable-print-preview,--disable-search-engine-choice-screen,--disable-partial-raster,--disable-in-process-stack-traces,--use-angle=swiftshader,--disable-low-res-tiling,--disable-speech-api,--disable-smooth-scrolling,--disable-default-apps,--disable-prompt-on-repost,--disable-domain-reliability,--enable-dom-distiller,--enable-distillability-service,--disable-component-update,--disable-background-timer-throttling,--disable-breakpad,--disable-crash-reporter,--disable-software-rasterizer,--disable-asynchronous-spellchecking,--disable-extensions,--disable-html5-camera,--noerrdialogs,--disable-popup-blocking,--disable-hang-monitor,--disable-checker-imaging,--enable-surface-synchronization,--disable-image-animation-resync,--disable-client-side-phishing-detection,--disable-component-extensions-with-background-pages,--run-all-compositor-stages-before-draw,--disable-background-networking,--disable-renderer-backgrounding,--disable-field-trial-config,--disable-back-forward-cache,--disable-backgrounding-occluded-windows,--log-level=3,--enable-logging=stderr,--font-render-hinting=none,--block-new-web-contents,--no-subproc-heap-profiling,--no-pre-read-main-dll,--disable-stack-profiler,--crash-on-hang-threads,--restore-last-session,--ip-protection-proxy-opt-out,--unsafely-disable-devtools-self-xss-warning,--enable-features=PdfOopif,SharedArrayBuffer,NetworkService,NetworkServiceInProcess,--metrics-recording-only,--use-mock-keychain,--force-color-profile=srgb,--disable-infobars,--mute-audio,--disable-datasaver-prompt,--no-service-autorun,--password-store=basic,--export-tagged-pdf,--no-pings,--rusty-png,--disable-histogram-customizer,--window-size=800,600,--disable-vulkan-fallback-to-gl-for-testing,--disable-vulkan-surface,--disable-webrtc,--disable-blink-features=AutomationControlled,--disable-ipc-flooding-protection,--disable-features=PaintHolding,HttpsUpgrades,DeferRendererTasksAfterInput,LensOverlay,ThirdPartyStoragePartitioning,IsolateSandboxedIframes,ProcessPerSiteUpToMainFrameThreshold,site-per-process,WebUIJSErrorReportingExtended,DIPS,InterestFeedContentSuggestions,PrivacySandboxSettings4,AutofillServerCommunication,CalculateNativeWinOcclusion,OptimizationHints,AudioServiceOutOfProcess,IsolateOrigins,ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate")
11+
MACHINE: Darwin/v10cpu
12+
DATE: 2025-02-25 12:37:12
13+
Total Duration: 1.318385833s
14+
Average Duration: 131.819904ms
15+
16+
<http://spider.cloud> - 10 SAMPLES
17+
CHROME_PATH: headless_shell
18+
CHROME_ARGS: (92)("--remote-debugging-address=0.0.0.0,--remote-debugging-port=9223,--headless,--disable-gpu,--disable-gpu-sandbox,--use-gl=angle,--no-first-run,--no-sandbox,--disable-setuid-sandbox,--no-zygote,--hide-scrollbars,--user-data-dir=~/.config/google-chrome,--allow-running-insecure-content,--autoplay-policy=user-gesture-required,--ignore-certificate-errors,--no-default-browser-check,--disable-dev-shm-usage,--disable-threaded-scrolling,--disable-cookie-encryption,--disable-demo-mode,--disable-dinosaur-easter-egg,--disable-fetching-hints-at-navigation-start,--disable-site-isolation-trials,--disable-web-security,--disable-threaded-animation,--disable-sync,--disable-print-preview,--disable-search-engine-choice-screen,--disable-partial-raster,--disable-in-process-stack-traces,--use-angle=swiftshader,--disable-low-res-tiling,--disable-speech-api,--disable-smooth-scrolling,--disable-default-apps,--disable-prompt-on-repost,--disable-domain-reliability,--enable-dom-distiller,--enable-distillability-service,--disable-component-update,--disable-background-timer-throttling,--disable-breakpad,--disable-crash-reporter,--disable-software-rasterizer,--disable-asynchronous-spellchecking,--disable-extensions,--disable-html5-camera,--noerrdialogs,--disable-popup-blocking,--disable-hang-monitor,--disable-checker-imaging,--enable-surface-synchronization,--disable-image-animation-resync,--disable-client-side-phishing-detection,--disable-component-extensions-with-background-pages,--run-all-compositor-stages-before-draw,--disable-background-networking,--disable-renderer-backgrounding,--disable-field-trial-config,--disable-back-forward-cache,--disable-backgrounding-occluded-windows,--log-level=3,--enable-logging=stderr,--font-render-hinting=none,--block-new-web-contents,--no-subproc-heap-profiling,--no-pre-read-main-dll,--disable-stack-profiler,--crash-on-hang-threads,--restore-last-session,--ip-protection-proxy-opt-out,--unsafely-disable-devtools-self-xss-warning,--enable-features=PdfOopif,SharedArrayBuffer,NetworkService,NetworkServiceInProcess,--metrics-recording-only,--use-mock-keychain,--force-color-profile=srgb,--disable-infobars,--mute-audio,--disable-datasaver-prompt,--no-service-autorun,--password-store=basic,--export-tagged-pdf,--no-pings,--rusty-png,--disable-histogram-customizer,--window-size=800,600,--disable-vulkan-fallback-to-gl-for-testing,--disable-vulkan-surface,--disable-webrtc,--disable-blink-features=AutomationControlled,--disable-ipc-flooding-protection,--disable-features=PaintHolding,HttpsUpgrades,DeferRendererTasksAfterInput,LensOverlay,ThirdPartyStoragePartitioning,IsolateSandboxedIframes,ProcessPerSiteUpToMainFrameThreshold,site-per-process,WebUIJSErrorReportingExtended,DIPS,InterestFeedContentSuggestions,PrivacySandboxSettings4,AutofillServerCommunication,CalculateNativeWinOcclusion,OptimizationHints,AudioServiceOutOfProcess,IsolateOrigins,ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate")
19+
MACHINE: Darwin/v10cpu
20+
DATE: 2025-02-25 13:16:20
21+
Total Duration: 1.6137815s
22+
Average Duration: 161.360071ms
23+

benches/logs/Darwin_v10cpu_benchmark_noargs_logs.txt

+16
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,19 @@ MACHINE: Darwin/v10cpu
55
DATE: 2025-02-25 09:49:33
66
Average Duration: 170.837966ms
77

8+
<http://spider.cloud> - 10 SAMPLES
9+
CHROME_PATH: headless_shell
10+
CHROME_ARGS: (6)("--remote-debugging-address=0.0.0.0,--remote-debugging-port=9223,--headless,--disable-gpu,--disable-gpu-sandbox,--use-gl=angle")
11+
MACHINE: Darwin/v10cpu
12+
DATE: 2025-02-25 12:37:16
13+
Total Duration: 1.45234475s
14+
Average Duration: 145.212333ms
15+
16+
<http://spider.cloud> - 10 SAMPLES
17+
CHROME_PATH: headless_shell
18+
CHROME_ARGS: (6)("--remote-debugging-address=0.0.0.0,--remote-debugging-port=9223,--headless,--disable-gpu,--disable-gpu-sandbox,--use-gl=angle")
19+
MACHINE: Darwin/v10cpu
20+
DATE: 2025-02-25 13:16:24
21+
Total Duration: 1.372718833s
22+
Average Duration: 137.257075ms
23+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<http://spider.cloud> - 10 SAMPLES
2+
CHROME_PATH: headless_shell
3+
CHROME_ARGS: (92)("--remote-debugging-address=0.0.0.0,--remote-debugging-port=9223,--headless,--disable-gpu,--disable-gpu-sandbox,--use-gl=angle,--no-first-run,--no-sandbox,--disable-setuid-sandbox,--no-zygote,--hide-scrollbars,--user-data-dir=~/.config/google-chrome,--allow-running-insecure-content,--autoplay-policy=user-gesture-required,--ignore-certificate-errors,--no-default-browser-check,--disable-dev-shm-usage,--disable-threaded-scrolling,--disable-cookie-encryption,--disable-demo-mode,--disable-dinosaur-easter-egg,--disable-fetching-hints-at-navigation-start,--disable-site-isolation-trials,--disable-web-security,--disable-threaded-animation,--disable-sync,--disable-print-preview,--disable-search-engine-choice-screen,--disable-partial-raster,--disable-in-process-stack-traces,--use-angle=swiftshader,--disable-low-res-tiling,--disable-speech-api,--disable-smooth-scrolling,--disable-default-apps,--disable-prompt-on-repost,--disable-domain-reliability,--enable-dom-distiller,--enable-distillability-service,--disable-component-update,--disable-background-timer-throttling,--disable-breakpad,--disable-crash-reporter,--disable-software-rasterizer,--disable-asynchronous-spellchecking,--disable-extensions,--disable-html5-camera,--noerrdialogs,--disable-popup-blocking,--disable-hang-monitor,--disable-checker-imaging,--enable-surface-synchronization,--disable-image-animation-resync,--disable-client-side-phishing-detection,--disable-component-extensions-with-background-pages,--run-all-compositor-stages-before-draw,--disable-background-networking,--disable-renderer-backgrounding,--disable-field-trial-config,--disable-back-forward-cache,--disable-backgrounding-occluded-windows,--log-level=3,--enable-logging=stderr,--font-render-hinting=none,--block-new-web-contents,--no-subproc-heap-profiling,--no-pre-read-main-dll,--disable-stack-profiler,--crash-on-hang-threads,--restore-last-session,--ip-protection-proxy-opt-out,--unsafely-disable-devtools-self-xss-warning,--enable-features=PdfOopif,SharedArrayBuffer,NetworkService,NetworkServiceInProcess,--metrics-recording-only,--use-mock-keychain,--force-color-profile=srgb,--disable-infobars,--mute-audio,--disable-datasaver-prompt,--no-service-autorun,--password-store=basic,--export-tagged-pdf,--no-pings,--rusty-png,--disable-histogram-customizer,--window-size=800,600,--disable-vulkan-fallback-to-gl-for-testing,--disable-vulkan-surface,--disable-webrtc,--disable-blink-features=AutomationControlled,--disable-ipc-flooding-protection,--disable-features=PaintHolding,HttpsUpgrades,DeferRendererTasksAfterInput,LensOverlay,ThirdPartyStoragePartitioning,IsolateSandboxedIframes,ProcessPerSiteUpToMainFrameThreshold,site-per-process,WebUIJSErrorReportingExtended,DIPS,InterestFeedContentSuggestions,PrivacySandboxSettings4,AutofillServerCommunication,CalculateNativeWinOcclusion,OptimizationHints,AudioServiceOutOfProcess,IsolateOrigins,ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate")
4+
MACHINE: Darwin/v10cpu
5+
DATE: 2025-02-25 13:16:21
6+
Total Duration: 591.746834ms
7+
Average Duration: 377.343866ms
8+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<http://spider.cloud> - 10 SAMPLES
2+
CHROME_PATH: headless_shell
3+
CHROME_ARGS: (6)("--remote-debugging-address=0.0.0.0,--remote-debugging-port=9223,--headless,--disable-gpu,--disable-gpu-sandbox,--use-gl=angle")
4+
MACHINE: Darwin/v10cpu
5+
DATE: 2025-02-25 13:16:24
6+
Total Duration: 609.04825ms
7+
Average Duration: 394.105729ms
8+

benches/logs_concurrent/Linux_v4cpu_benchmark_logs.txt

Whitespace-only changes.

benches/logs_concurrent/Linux_v4cpu_benchmark_noargs_logs.txt

Whitespace-only changes.

benches/run.rs

+18-8
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ pub async fn run(log_file_name: &str) {
1717
ensure_log_directory_exists(LOG_DIR).expect("Failed to create log directory");
1818
let query = env::var("BENCH_URL").unwrap_or_else(|_| "http://spider.cloud".into());
1919
let mut total_duration = Duration::new(0, 0);
20-
21-
headless_browser_lib::fork(Some(*headless_browser_lib::conf::DEFAULT_PORT)).await;
22-
tokio::spawn(headless_browser_lib::run_main());
23-
tokio::time::sleep(Duration::from_millis(1000)).await; // Wait for the server to load.
20+
let current_time = Instant::now();
2421

2522
for i in 0..SAMPLE_COUNT {
2623
println!("Running sample {} of {}", i + 1, SAMPLE_COUNT);
@@ -39,8 +36,15 @@ pub async fn run(log_file_name: &str) {
3936
}
4037

4138
let average_duration = total_duration.div(SAMPLE_COUNT);
42-
println!("Finished average time: {:?}", average_duration);
43-
log_performance(average_duration, &query, log_file_name).expect("Failed to log performance");
39+
let total_time = current_time.elapsed();
40+
41+
println!(
42+
"Finished average time: {:?} - total time: {:?}",
43+
average_duration,total_time
44+
);
45+
46+
log_performance(total_time, average_duration, &query, log_file_name)
47+
.expect("Failed to log performance");
4448
}
4549

4650
/// Ensure the dir always exist.
@@ -52,7 +56,12 @@ fn ensure_log_directory_exists(dir: &str) -> io::Result<()> {
5256
}
5357

5458
/// Log the performance to file.
55-
fn log_performance(current_avg: Duration, query: &str, log_file_name: &str) -> io::Result<()> {
59+
fn log_performance(
60+
total_duration: Duration,
61+
current_avg: Duration,
62+
query: &str,
63+
log_file_name: &str,
64+
) -> io::Result<()> {
5665
let os_type = sys_info::os_type().unwrap_or_default();
5766
let cpu_count = sys_info::cpu_num().unwrap_or_default().to_string();
5867
let sanitized_os = os_type.replace(|c: char| !c.is_alphanumeric(), "_");
@@ -106,11 +115,12 @@ fn log_performance(current_avg: Duration, query: &str, log_file_name: &str) -> i
106115

107116
writeln!(
108117
log_file,
109-
"<{query}> - {SAMPLE_COUNT} SAMPLES\nCHROME_PATH: {}\nCHROME_ARGS: {}\nMACHINE: {}\nDATE: {}\nAverage Duration: {:?}\n",
118+
"<{query}> - {SAMPLE_COUNT} SAMPLES\nCHROME_PATH: {}\nCHROME_ARGS: {}\nMACHINE: {}\nDATE: {}\nTotal Duration: {:?}\nAverage Duration: {:?}\n",
110119
chrome_path,
111120
chrome_args,
112121
format!("{}/v{}cpu", os_type, cpu_count),
113122
chrono::Local::now().format("%Y-%m-%d %H:%M:%S"),
123+
total_duration,
114124
current_avg
115125
)?;
116126
}

0 commit comments

Comments
 (0)