Persistent homology of directed spaces