Category Archives: Optimization
Load testing tools
https://yandex.ru/dev/tank/ [Tool | Free] https://jmeter.apache.org/ [Tool | Free] http://tsung.erlang-projects.org/ [Tool | Free] https://gatling.io/ [Tool | Free/$] https://k6.io/ [Tool | Free/SaaS] https://locust.io/ [Tool | Free] https://loader.io/ [SaaS | Free/$] https://artillery.io [Tool | Free/$] https://github.com/wg/wrk [Tool | Free]
How to analyze the performance of your go application in production
You should definitely use chi’s middleware for running pprof and stuff in your admin panel. That’s the repo — https://github.com/go-chi/chi That’s the profiler — https://github.com/go-chi/chi/blob/master/middleware/profiler.go CPU profiling After that you can run something like this in shell:
1 |
go tool pprof -png ~/Downloads/profile |
Or just open it in the browser:
1 |
go tool pprof -http=:1234 ~/Downloads/profile |
If it opens something different then your browser (sublime …
Simple way to detect browser’s FPS via JS
It’s dumb and dead simple but works. You can even track browser’s metrics with that.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
(() => { const times = []; let fps; function refreshLoop() { window.requestAnimationFrame(() => { const now = performance.now(); while (times.length > 0 && times[0] <= now - 1000) { times.shift(); } times.push(now); fps = times.length; refreshLoop(); }); } refreshLoop(); // output to console once per second setInterval(() => {console.log(fps);}, 1000) })(); |
Cool talk on js event loop and call stack
It’s junior-middle level, but animations are nice as well. https://youtu.be/8aGhZQkoFbQ Here’s an article about almost the same but in more details about difference between tasks’ queue (timeouts) and microtasks’ queue (promises and DOM modifications). The main idea is that there are several queues that have different priorities. And microtasks are more important than tasks. https://jakearchibald.com/2015/tasks-microtasks-queues-and-schedules/
React. Benchmarking and optimizing performance
There is a tool called react-addons-perf that should be imported into your project.
1 2 3 |
import Perf from 'react-addons-perf'; window.Perf = Perf; |
After that you can use Perf object in your console. It can tell you about your react performance issues, not including redux. For instance, you can check unnecessary renders or unnecessary change calculations:
1 2 3 4 5 6 |
Perf.start(); // do whatever you want to measure Perf.stop(); Perf.printOperations(); // to show DOM manipulations Perf.printWaisted(); // to show unneeded calculations for components which remained the same afterwards |
Here’s more on that — https://reactjs.org/docs/perf.html. And …
SQL. Как переписать correlation subquery в JOIN to derived table
Допустим есть такая таблица
Отладка сторонних скриптов в Google Chrome
Если у вас есть на сайте какая-нибудь вредная система, которая вставляет произвольные скрипты на сайт, то рано или поздно встаёт проблема с тем, что их нужно отладить. В Google Chrome это можно сделать так: .
Как выявить лишние стили на сайте
https://github.com/ben-eb/gulp-uncss https://github.com/addyosmani/critical
Загрузка css, которая не блокирует загрузку страницы
Забавный хак-костыль, вдруг когда-нибудь пригодится. Конечно, лучше сначала загрузить critical path css, а все остальные стили убрать в конец страницы (при этом загрузка css не будет мешать загрузке кода страницы), но вдруг пригодится:
1 2 |
<link rel="stylesheet" href="css.css" media="none" onload="if(media!='all')media='all'"> <noscript><link rel="stylesheet" href="css.css"></noscript> |
http://keithclark.co.uk/articles/loading-css-without-blocking-render/
Chrome Dev Tools Filmstrip View
Что это Это дополнительная кнопка во вкладке «Сеть» в Google Chrome, которая показывает «раскадровку». Как включить Make sure you are on Chrome 44.0.2388.0+ Go to chrome://flags Find Enable Developer Tools experiments and enable it. Click the gear icon. Go to Experiments in the left hand sidebar. Press shift 6 times to reveal hidden features. Enable …