Skip to content

tdoan123/WorkerBenchmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WorkerBenchmark

A .NET 10 console application that benchmarks two worker scheduling strategies for processing subscription expiry — measuring the real cost difference in database reads, execution time, CPU, and memory.

What It Tests

Worker Schedule Strategy
OnceDailyWorker Once per day Fetch and bulk-update all expired subscriptions in one operation
EveryMinuteWorker Every minute (1,440×/day) Same logic, repeated every minute to simulate a polling pattern

Both workers produce identical results. The benchmark measures the overhead of running the same operation too frequently.

Requirements

Getting Started

Clone the repository and run:

git clone https://github.com/tdoan123/WorkerBenchmark.git
cd WorkerBenchmark
dotnet run

The app will:

  1. Seed 2,000 counsellors and subscriptions (~20% expired) into a local SQLite database
  2. Run both workers across three benchmark rounds
  3. Print a performance and cost comparison table to the console

Benchmark Rounds

Round Latency Memory Measurement
Round 1 0ms (local baseline) Net heap delta
Round 2 1ms simulated per DB call Net heap delta
Round 3 0ms Total allocated bytes (GC-aware)

Results & Report

Full findings, methodology, cost assumptions, and analysis are documented in the

Project Structure

WorkerBenchmark/
├── Models/
│   ├── Counsellor.cs          # Counsellor entity + CounsellorRole enum
│   └── Subscription.cs        # Subscription entity + SubscriptionStatus enum
├── Data/
│   ├── AppDbContext.cs         # EF Core DbContext
│   ├── SqlCounterInterceptor.cs# Counts SELECTs/UPDATEs, injects simulated latency
│   └── SeedData.cs            # Seeds 2,000 counsellors and subscriptions
├── Workers/
│   ├── OnceDailyWorker.cs     # Runs once, bulk-updates expired subscriptions
│   └── EveryMinuteWorker.cs   # Same logic, runs 1,440 times
├── Program.cs                 # Orchestrates benchmark rounds, prints results
├── REPORT.md                  # Full benchmark report
└── benchmark.db               # SQLite database (auto-created on run)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages