Tuesday, November 8, 2016

C# performance notes


  • for v.s foreach
    1. for loops on List are a bit more than 2 times cheaper than foreach loops on List.
    2. Looping on Array is around 2 times cheaper than looping on List.
    3. As a consequence, looping on Array using for is 5 times cheaper than looping on List using foreach.
    4. LinkedList only allows foreach loops, as it would take quadratic time to loop a LinkedList through indices.
    5. Looping overheads: for < foreach; Array ~ List < ArrayList < LinkedList
  • Everything stored in an ArrayList is an object. So be careful of the boxing/unboxing overhead.
  • String concatenation overheads are negligible outside loops. 

Monday, May 9, 2016

Sunday, April 10, 2016

Converts videos to WebM with aconv/ffmpeg

Using aconv:
http://daniemon.com/blog/how-to-convert-videos-to-webm-with-ffmpeg/

Using ffmpeg:
http://trac.ffmpeg.org/wiki/Encode/VP8

Example code:
ffmpeg -i $INPUT -c:v libvpx -crf 4 -b:v 10M -c:a libvorbis $OUTPUT
The above command converts the input file to webm with a variable bitrate in a constant quality mode, which ensures that every frame achieve a certain quality level. In this command, -b:v 10M sets the maximum allowed bitrate to 10 MBit/s and -crf 4 sets the constant quality to 4 (best quality).