It seems like you could compare the returns of your actual portfolio to the returns of a hypothetical portfolio in which cash is replaced by your actual stock holdings at proportional weights (or replaced with the previous portfolio when cash is 100%).
An easier calculation might be to compare the S&P 500 to a hypothetical portfolio in which cash allocation is identical to your actual portfolio, but your stocks are replaced by the S&P 500. The difference would be attributable to market timing. However, unlike the first method, this wouldn't measure the timing of your specific investment decisions, e.g. selling a particular stock at an opportune time.