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 7694649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:22:01+00:00 2026-05-31T21:22:01+00:00

I have this function: show_employee_table() -> do(qlc:q([B || B <- mnesia:table(employee)])). What it does

  • 0

I have this function:

show_employee_table() ->
    do(qlc:q([B || B <- mnesia:table(employee)])).

What it does is that it goes to a table called employee and prints the contents to the user.

Concept: I want to make another function say called show(times) -->, this function will take a table name and the number of times to call the show_table function.

If I input (employee,100), I want to have a for loop that runs 100 times, the idea is to measure the time taken to run the loop. In java I would do something like this:

Time t = time.now();
for ( I=0; I<N; I++){
show_employee_table() ->
    do(qlc:q([B || B <- mnesia:table(employee)])).
}

Time t2 = time.now();

timetaken = t2 - t1;

That’s how I want to do it, but in erlang. I just don’t know the syntax in erlang and I would appreciate it if someone can help me.

  • 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-31T21:22:02+00:00Added an answer on May 31, 2026 at 9:22 pm

    For time measurement, use: timer:tc/1, timer:tc/2, timer:tc/3. So we will have a recursive function called loop which may be doing anything you want. Then we would measure the time it takes to loop by applying

    {TimeTaken,Result} = timer:tc(?MODULE,loop,Args).
    

    Args must be a list of arguments to the function say, a table and a number, like this

    measureLoopTime()->
       Args = [employee,100],
       {TimeTaken,_Result} = timer:tc(?MODULE,loop,Args),
       TimeTaken.
    
    loop(_,0) -> done;
    loop(Table,Number)->
      %%% do something ....
      loop(Table, Number - 1).
    

    That’s the correct erlang implementation of your java code. Follow the link to the timing function to see in which units the time is returned.

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

Sidebar

Related Questions

I have this function in my Javascript Code that updates html fields with their
I have this function on my controller (Im using CodeIgniter) that reads the database,
Ok, so I have this jquery function to that grabs the checkbox's value and
I have this function which evaluates the contents of a textbox (or combobox or
I have this big function (1300+ lines of code) that takes data from the
I have this function that puts some data with Ajax call in a php
I have this function that checks a UK postcode. The problem is that it
I have this function that checks if a page is the parent: function is_tree($pid)
I have this function: function view ( $id ) { $this->layout = 'page'; $this->User->id
I have this code that I run when a user submits a form (this

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.