From my understanding of mining as it is a completely random process what determines the hashrate of a worker is the frequency with which the worker can deliver valid shares that are above a certain lower difficulty threshold.
The pool tells the worker (gives work items) to report back only if it finds a share above difficulty x. This threshold x has to be chosen based on the worker's capabilites and is subject to be adjusted on-the-fly. The worker shouldn't have to report back too often, with too high frequency (work items have too low difficulty for worker's hashpower) and also not with too low frequency as the pool then might not know if the worker is actually doing some work.
I think it's a misconception to calculate the hashrate based on the specific difficulty value of a submitted share. You should observe the frequency with which a certain difficulty is exceeded, regardless of the specific value that exceeded the lower limit.
If I'm not wrong (see
https://en.bitcoin.it/wiki/Difficulty) to statistically exceed difficulty D in timeframe 600s you have to execute a hashrate of at least D * 2
32 / 600. To sample with higher frequency you can adjust accordingly.
The mining pool code of ckPool is open-source. Last time I looked at the code, I don't remember it very well documented. You may have a look at the code, if you haven't done so already. Repository link is
https://bitbucket.org/ckolivas/ckpool