Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3606644
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:16:32+00:00 2026-05-18T21:16:32+00:00

I was thinking about how to implement a process that gives the number of

  • 0

I was thinking about how to implement a process that gives the number of discrete intervals in time that occurred since it started.
Am I losing accuracy here? How do I implement this without loss of accuracy after a while and after heavy client abuse. I am kind of stumped on how to do this in Erlang.

Naturally I don’t want to use a system call such as now().

-module(clock).
-compile([export_all]).

start(Time) ->
    register(clock, spawn(fun() -> tick(Time, 0) end)).

stop() -> clock ! stop.

tick(Time, Count) ->
    receive
        nticks ->
            io:format("~p ticks have passed since start~n", [Count])
    after 0 -> true
    end,
    receive
        stop ->
            void
    after Time ->
            tick(Time, Count + 1)
    end.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T21:16:32+00:00Added an answer on May 18, 2026 at 9:16 pm

    Manual tick counting like you’re doing is not going to be accurate due to slight scheduling fluctuations as well as function execution overhead.

    What you want to do is grab a timestamp when the process starts and pass that in to each recursive call to the function. Then, when you want to grab the number of ticks (in microseconds) that have elapsed since you started the process, grab a new timestamp and pass them both into now_diff.

    It looks like you’re using your own concept of “ticks”, so you can just figure out how many microseconds your “tick” is and divide your end result by it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thinking about a Windows-hosted build process that will periodically drop files to disk to
Thinking about avoiding code replication, I got a question that catches me every time
After watching this video , I started thinking about how I could implement something
I'm thinking about using the java application object to implement a simple cache, to
Recently I've been thinking about finite state machines (FSMs), and how I would implement
I've been thinking about using shared pointers, and I know how to implement one
I'm starting to write a small web application and have started thinking about securing
I was thinking about moving from ASMX to WCF to implement web services. One
I'm thinking about how can I implement onfocus and onblur effects in my input
I've been playing around with Scala recently and was thinking about how to implement

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.