TwitchToYoutube/benchmark.md
Fijxu b63cf6d8c4 Pequeño cambio en el script.
- Ofrecer versión del script con xh y jtc
- Explicación de porque usar la nueva version del script es mejor
- + Ejecutable jtc
- ppL
2022-11-22 16:33:53 -03:00

1.4 KiB

cURL/jq o xh/jtc?

Bueno, quise hacer otra version del script usando diferentes programas, me di cuenta que jq usaba mucho CPU para sortear (del ingles sort) el archivo .json necesario para detectar si el streamer esta en vivo o no.

Entonces busque por alternativas y encontré xh (Alternativa a cURL hecha en Rust 🏳‍⚧️) y jtc (Alternativa a jq hecha en C++).

Luego me hice a hacer unos benchmarks usando hyperfine y los tiempos y el uso de CPU fueron menores a las herramientas que generalmente se usan por defecto (cURL y jq).

⚙ Benchmarks

cURL y jq

curl -sS -X GET "https://api.twitch.tv/helix/streams?user_login=Suwie" -H "Authorization: Bearer $twitchauth" -H "Client-Id: $clientid" | jq -r '.data[].type'

https://ii.zzls.xyz/NIZPQTI.png

xh y jtc

xh GET "https://api.twitch.tv/helix/streams?user_login=Suwie" "Authorization: Bearer $twitchauth" "Client-Id: $clientid" -b | ./jtc -w '[data][:][type]'

https://ii.zzls.xyz/AFHFXYI.png


Los tiempos de ejecución y uso de CPU son exponencialmente menores a curl y jq con una diferencia de ~150ms.

Entonces si vas a usar este script, es mejor usar la nueva version por ser exponencialmente mas efectiva.

https://cdn.7tv.app/emote/63065b70be8c19d70f9d6633/3x.webp