Question regarding sampling rate of sine wave
The assumption here is the sine wave being samples is a known and assumed accurate reference, and the sampling rate is the unknown.
An algorithm that utilizes every sample with equal weight would provide for the best estimate assuming a white noise process. The approach the OP uses, and any similar &quot;edge-detection&quot; methods where we are making a decision on a cycle boundary and then measuring the distance between two such decisions, are prone to significantly higher errors under lower SNR conditions due to the sensitivity of noise on just the two decisions used; as done the noise effecting the result is the rms of the noise for each of the two decisions so is additive as well.
Such algorithms for determining the frequency of a single tone are well documented (see Question regarding estimation of signal tone parameters (frequency, amplitude, and phase) using Macleods algorithm). The approach would be to use these techniques with a scaled frequency designating the tone frequency to be determined as a frequency ratio relative to the sampleing rate $(f/f_s)$ rather than absolute frequency. Thus once $f/f_s$ is determined with such estimators, and with $f$ known, $f_s$ can be accurately determined.
The FFT is one such algorithm that uses every sample to provide a best estimate (under white noise conditions), but for the case of a single tone, the above references would provide more optimized solutions. See https://www.dsprelated.com/showarticle/1284.php where @CedronDawg worked through the math to derive the precise frequency estimate from two adjacent bins in the FFT result (for all the likely cases when the actual frequency is not centered on a bin), so that could be combined with the Goertzel algorithm which efficiently solves for a smaller subset of all DFT bins for a reasonable solution.