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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:40:30+00:00 2026-06-14T04:40:30+00:00

I have several functions in main that output information. I need to measure their

  • 0

I have several functions in main that output information.

I need to measure their execution time.

Currently it’s done like this:

  start <- getCurrentTime
  putStrLn $ show $ findNthMinLinear (getTestArrayOfLength (read arrlength :: Int)) 4
  stop <- getCurrentTime
  print $ diffUTCTime stop start

I want to wrap each function in a function that 1. remembers the time 2. evaluates function 3. remembers the time 4. prints difference between two remembered times

The problem is that i don’t know how to pass a function without evaluating it first.

My guess is that if i write (<5) for example, that is i create a function that returns a function, no real work will be done until i pass final parameter i guess?
Then i could write

printAndMeasure :: (a -> IO()) -> IO ()
...
printAndMeasure \x -> (getTestArrayOfLength (read arrlength :: Int)) 4

but it’s a sloppy solution because i don’t really need this x other than to hold function from being executed.

  • 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-06-14T04:40:31+00:00Added an answer on June 14, 2026 at 4:40 am

    Passing a function does not evaluate it. So you can have function like IO () -> IO () and pass IO actions to them. When a program is run only main function is executed and arguments of a function are not evaluated until needed (laziness).
    If you are trying to benchmark your code then it is better to use benchmarking libraries like Criterion.

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

Sidebar

Related Questions

I have several modules (mainly C) that need to be redesigned (using C++). Currently,
I have a Bourne Shell script that has several functions in it, and allows
I have developed several general purpose script functions, for Google Spreadsheet apps. Currently I
I have noticed that Google Toolbox for Mac replaces several SQLite built-in functions (LOWER/UPPER,
I'm building a program that has several functions that need to read data from
I have several functions running in my main js file and after I added
I have an UI application that serves several functions (<800KB). I wanted to allow
In a C project, I have a main() function in several files. When I
I have a several functions which are quite large, and are only used in
I have several onmouseover events (combination of javascript functions and jquery accordions) but they

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.