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

The Archive Base Latest Questions

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

I found partial solutions on several sites, so I pulled several parts together, but

  • 0

I found partial solutions on several sites, so I pulled several parts together, but I still couldn’t figure it out.

Here is what I am doing:

I am running a simple java program from Terminal, and need to find the average runtime for the program.

What I am doing is running the command several times, finding the total time, and then dividing that total time by the number of times I ran the program.

I would also like to acquire the output of the program rather than displaying it on standard output.

Here is my current code and the output.

Shell Script:

   startTime=$(date +%s%N)
   for ((i = 0; i <  $runTimes; i++))
   do
            java Program test.txt > /dev/null
   done
   endTime=$(date +%s%N)
   timeDiff=$(( $endTime - $startTime ))
   timeAvg=$(( $timeDiff / $numTimes ))
   echo "Avg Time Taken: "
   echo $timeAvg

Output:

 ./run: line 12: 1305249784N: value too great for base (error token is "1305249784N")

The line number 12 is off because this code is part of a larger file.
The line number 12 is the line with timeDiff being evaluated.

I appreciate any help, and apologize if this question is redundant or off-topic.

  • 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-22T01:25:32+00:00Added an answer on May 22, 2026 at 1:25 am

    On my machine, I don’t see what the %N format for date is getting you, as the value seems to be 7 zeros, BUT it is making a much bigger number to evaluate in the math, i.e. 1305250833570000000. Do you really need nano-second precision? I’ll bet if you go with just %s it will be fine.

    Otherwise you look to be on the right track.

    P.S.

    Oh yeah, minor point,

     echo "Avg Time Taken:  $timeAvg" 
    

    Is a a simpler way to achieve your required output 😉

    Option 2. You could take out the date calculations all together, and turn your loop into a small script. Then you can use a built-in feature of the shell

    time myJavaTest.sh
    

    Will give you details like

    real    0m0.049s
    user    0m0.016s
    sys     0m0.015s
    

    I hope this helps.

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

Sidebar

Related Questions

Update: I've found a partial solution in this answer here , by adding the
Found this: Sub SurroundWithAppendTag() DTE.ActiveDocument.Selection.Text = .Append( + DTE.ActiveDocument.Selection.Text + ) End Sub But
i am using asp.net mvc 2.0. in that i am using partial views but
Now that I've upgraded to Rails 3, I'm trying to figure out the proper
Before going into my problem, I will post reference where I found partial solution:
found this regex: insert every 10 characters: $text = preg_replace(|(.{10})|u, \${1}. , $text); can
Found a piece of code today, that I find a little smelly... TMyObject.LoadFromFile(const filename:
Found this rather strange bug in IE8; element.style.top is limited to 1342177 pixels. Even
Found two libraries Rebex ( www.rebex.net ) and QuikSoft ( www.quiksoft.com ) any comments
Found very strange behavior of MS Access database when running queries from c#. It

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.