From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: how to analyze clock drift Date: Wed, 19 Nov 2014 10:01:10 +0100 Organization: cbb software GmbH Message-ID: <1nvfhit2csxr5.41v36jksch28$.dlg@40tude.net> References: <6uun6alsp3jh1pob6g9qgcg85etqgenmd0@4ax.com> <87zjbn3nss.fsf@debian.uxu> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: nyHeW7QjJmC1odUjK4LkDA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:23540 Date: 2014-11-19T10:01:10+01:00 List-Id: On Wed, 19 Nov 2014 03:51:47 +0100, Emanuel Berg wrote: > tmoran@acm.org writes: > >> To quote Richard Hamming "The purpose of computing >> is insight, not numbers". What is it that you want >> to know here? How do you hope to make use of what >> you learn? > > It is a Master project in CS. > > My teacher said those C++ timers aren't rock-solid. You certainly can use OS services from C++, instead of them. > Can I use them anyway? I asked. > > Yes, but output the tick times, and analyze just how > "not rock-solid" they are, he said. (Pseudo quotes.) You need a reference clock to measure drift and jitter. If you use sleep, there is a trend you cannot estimate (that is why Ada has delay and delay until). So you would not know which part of the drift is due to the clock deviation (that is typically somewhere around 5 µs/s) and which part is due to the sleep's systematic error. > That's what I'm trying to do. Basically you need to identify the model Tc = Tr + a * Tr + e Tc is C++ clock. Tr is the reference clock. Both start at 0 (the epoch). a is the constant deviation. e is a random error (jitter). Both a and e are contaminated by the systematic sleep error. This is a simple linear regression, which you can find in almost any statistical package or application. You also can implement it yourself. The regression will give you the value of a and the mean of e. Having a you can estimate the dispersion of e. It is to expect that e is not really normally distributed, so you could try to verify other hypotheses of distributions (statistical packages have tools for that). However I would consider it wasting time. Regarding being rock-solid, it probably the jitter was meant. In your case jitter also includes errors induced by OS services, e.g. by scheduling of the process and the task, by timer interrupt frequency when the clock is driven from there etc. All this contributes to the mean and the dispersion of e. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de