grafov / m3u8

Parser and generator of M3U8-playlists for Apple HLS. Library for Go language. :cinema:
http://tools.ietf.org/html/draft-pantos-http-live-streaming
BSD 3-Clause "New" or "Revised" License
1.22k stars 312 forks source link

Improve performance of parsing media playlists #174

Open eric opened 3 years ago

eric commented 3 years ago

I tried benchmarking an m3u8 with lots of attributes and found that there were some simple places to reduce memory usage and speed up parsing.

Here's a benchmark of the difference:

before

BenchmarkDecodeMediaPlaylistWithAttributes-16             50      23400226 ns/op

after

BenchmarkDecodeMediaPlaylistWithAttributes-16            142       8324689 ns/op