Add two functions to stack time segments and calculate std devs.

Cherry-picked from commit c55780de6e56c3cef799e02bc03d4ccfe04b7cb5 on graphite master.