Let $X_1, X_2, \ldots, X_d$ be $n \times n$ matrices over some field $K.$ I want to calculate the dimension of the unital algebra generated by $X_1, X_2, \ldots, X_d$ for some examples in a problem I am working on. If $d=1,$ we only have one $X,$ and the dimension is equal to the degree of the minimum polynomial of $X.$ For $d>1,$ the problem, is less clear. For example, the unital algebra generated by $$X_1=\left(\begin{matrix} 0 & 1 \\ 0 & 0 \end{matrix}\right), X_2=\left(\begin{matrix} 1 & 0 \\ 0 & 0 \end{matrix}\right)$$ is three dimensional.
Is there a good theoretical characterization of calculating the dimension in general? That is, is there some relatively easy to understand object (like the minimum polynomial) which gives you the dimension?
EDIT: Here, I'm interested if there are known solutions to the problem which are algorithmically fast and not the generic case.