Let's derive the proof. Consider you are short an option and long its self-financing delta hedge. You get the portfolio $\Pi$ whose $t$-value verifies
$$ \Pi_t = \underbrace{- V_t}_{\text{Short option}} + \underbrace{\Delta_t S_t}_{\text{Long stocks}} + \underbrace{\frac{(V_t - \Delta_t S_t)}{B_t} B_t}_{\text{Residual cash position}} $$
At time $t$, this position is worth zero: the option is perfectly replicated by the hedge. As soon as time will pass though, you will need to rebalance your hedge to remain delta neutral. Let's see what happens in-between two rebalancing dates when we keep the delta unchanged over say $[t,t+dt[$.
Because the strategy is self-financing, assuming the risk-free money market account verifies the ODE $dB_t = B_t r dt$ and the stock pays no dividends then we have that the replication error over $[t,t+dt[$ writes
$$ d\Pi_t = - dV_t + \Delta_t dS_t + (V_t - \Delta_t S_t) r dt \tag{0} $$
Let's expand the different terms at the lowest trivial order. If we consider a pure diffusion model (no jumps) this means order 1 in $dt$ and order 2 in $dS_t$. Assuming you're pricing the option $V_t$ under a BS framework with volatility $\sigma$, Itô's lemma gives
\begin{align}
dV_t &= \frac{\partial V}{\partial t} dt + \frac{\partial V}{\partial t} dS_t + \frac{1}{2} \frac{\partial^2 V}{\partial S^2} d\langle S \rangle_t \\
&= \theta_t dt + \Delta_t dS_t + \Gamma_t d\langle S \rangle_t
\end{align}
Plugging this in $(0)$ yields
$$ d\Pi_t = \underbrace{(-\theta_t - rS_t \Delta_t + rV_t)dt}_{\text{(a)}} - \Gamma d\langle S \rangle_t \tag{1} $$
The first terms $(a)$ should look familiar. Indeed, if you're pricing under the BS framework, then $v_t = V(t,S_t)$ ought to verify the BS pricing PDE
$$ \theta_t + r S_t \Delta_t + \frac{1}{2} \Gamma S_t^2 \sigma^2 - r V_t = 0$$
Using this to rewrite $(1)$ yields the following replication error over the period $[t,t+dt[$
\begin{align}
d\Pi_t &= \frac{1}{2} \Gamma S_t^2 \sigma^2 dt - \Gamma d \langle S \rangle_t \\
&= \frac{1}{2} \Gamma S_t^2 \left( \sigma^2 - \frac{d \langle S \rangle_t}{(S_t)^2 dt} \right) dt \\
&= \frac{1}{2} \Gamma S_t^2 \left( \sigma^2 - \beta_t^2 \right) dt
\end{align}
where $\beta^2$ is the "realised" quadratic variation of the log returns, i.e. not the one postulated and priced in by your model but the manner in which the market truly behaves.
Now if you want to find out the total replication error up to the maturity $T$ as seen from current time $t$, all which is left to do is to integrate and discount the infinitesimal P\&L leaks described above
$$ P\&L_t = \int_0^T e^{-r(T-t)} \frac{1}{2} \Gamma S_t^2 \left( \sigma^2 - \beta_t^2 \right) dt $$
This is a very interesting and well-known equation because it ties 3 important concepts:
$$ \int_0^T e^{-r(T-t)} \frac{1}{2} \underbrace{\Gamma}_{\text{Instrument related}} S_t^2 \left( \underbrace{\sigma^2}_{\text{Model related}} - \underbrace{\beta_t^2}_{\text{Market related}} \right) dt $$
A naive interpretation of it would go like this. Suppose I sold a vanilla option by pricing in a future volatility of $\sigma$ at inception. If the realised volatility $\beta$ is always higher than $\sigma$, then I expect to lose money since this would amount to me having effectively underpriced the option (note that the $\Gamma$ of a vanilla option is always positive).
The trick here is to observe that selling an option and delta hedging it dynamically is not a pure volatility trade though. The gamma term in the P\&L equation above introduces a path dependence: only along paths where $\Gamma(t,S_t)$ is not zero will the discrepancy between the pricing and realised vol accumulate and P\&L crystallise. You can find out more info in this related question.
Of course as mentioned in the comments, this P\&L equation assumes no transaction costs and continuous trading (when dynamically rebalancing the Delta). Also you are right in practice this is used to monitor the daily evolution of a delta-hedged portfolio ex post. It is usually part of the explained P&L calculations for instance.