cp .local.env .env
make env-up
make migrate-all-reset
make postgres-fixtures
make postgres-fixtures-count
# and
# make postgres-fixtures-clear
make env-up
make env-down
# or
# make env-down-with-clear
BENCHTIME=100x make bench
BenchmarkProfileStatsService
BenchmarkProfileStatsService-12 100 627990 ns/op 5033 B/op 80 allocs/op
PASS
ok github.com/u8views/go-u8views/internal/tests 0.088s
BENCHTIME=1000x make bench
BenchmarkProfileStatsService
BenchmarkProfileStatsService-12 1000 449478 ns/op 4124 B/op 72 allocs/op
PASS
ok github.com/u8views/go-u8views/internal/tests 0.471s
BENCHTIME=10000x make bench
BenchmarkProfileStatsService
BenchmarkProfileStatsService-12 10000 546875 ns/op 4885 B/op 81 allocs/op
PASS
ok github.com/u8views/go-u8views/internal/tests 5.492s
Benchmark (vultr.com VPS 1024.00 MB High Frequency) Intel Core Processor (Skylake, IBRS)
BENCHTIME=100x make bench
BenchmarkProfileStatsService
BenchmarkProfileStatsService 100 2275173 ns/op 1562 B/op 43 allocs/op
PASS
ok github.com/u8views/go-u8views/internal/tests 0.360s
BENCHTIME=1000x make bench
BenchmarkProfileStatsService
BenchmarkProfileStatsService 1000 2121516 ns/op 1571 B/op 44 allocs/op
PASS
ok github.com/u8views/go-u8views/internal/tests 2.153s
BENCHTIME=10000x make bench
BenchmarkProfileStatsService
BenchmarkProfileStatsService 10000 2153319 ns/op 1574 B/op 44 allocs/op
PASS
ok github.com/u8views/go-u8views/internal/tests 21.566s
SELECT user_id, SUM(count), COUNT(*)
FROM profile_hourly_views_stats
GROUP BY user_id
ORDER BY SUM(count) DESC
LIMIT 100;
SELECT g.time::TIMESTAMP
FROM (
SELECT time::TIMESTAMP
FROM generate_series(
(DATE_TRUNC('DAY', NOW()) - INTERVAL '1 MONTH')::TIMESTAMP,
(DATE_TRUNC('DAY', NOW()))::TIMESTAMP,
'1 DAY'::INTERVAL
) AS time
) AS g;
SELECT DATE_TRUNC('MONTH', time) AS month,
COUNT(*) AS views,
COUNT(DISTINCT (user_id)) AS users,
SUM("count") AS total
FROM profile_hourly_views_stats
GROUP BY 1
ORDER BY 1;
Month | Views | Users | Total |
---|---|---|---|
2023-01-01 | 15 | 3 | 78 |
2023-02-01 | 438 | 18 | 2700 |
2023-03-01 | 951 | 32 | 10241 |
2023-04-01 | 1110 | 36 | 3441 |
2023-05-01 | 2191 | 43 | 9032 |
2023-06-01 | 3433 | 57 | 16866 |
2023-07-01 | 3331 | 54 | 14233 |
2023-08-01 | 4539 | 69 | 18017 |
2023-09-01 | 4519 | 77 | 17053 |
2023-10-01 | 4473 | 78 | 15771 |
2023-11-01 | 4919 | 96 | 17567 |
2023-12-01 | 5525 | 115 | 19882 |
2024-01-01 | 11185 | 232 | 40202 |
2024-02-01 | 11348 | 245 | 39586 |
2024-03-01 | 13581 | 273 | 48629 |
2024-04-01 | 13613 | 291 | 47198 |
2024-05-01 | 14655 | 306 | 50581 |
2024-06-01 | 13924 | 319 | 57695 |
2024-07-01 | 5692 | 293 | 25950 |