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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:22:28+00:00 2026-06-10T14:22:28+00:00

I hav used the following code to display a result and time elapsed to

  • 0

I hav used the following code to display a result and time elapsed to find out the result in mod_wsgi.But watever i try i always get the elapsed time as 0 even though i rounded the time to nanoseconds. What do i do now to calculate the difference?

#!D:/Python27/python

from wsgiref.simple_server import make_server
from cgi import parse_qs, escape
import time
import datetime

html = """
<html>
<body>
  <h2>Sum of first n factorials</h2>
   <form method="get" action="Sec1q10.py">
      Number :<input type="text" name="t1">
<br> <input type="submit" value="Submit">
  </form>
   <br>
   Result:%s<br>
   Now:%s<br>
   End:%s<br>
   Time:%s
   </body>
</html>"""

def application(environ, start_response):
 d=parse_qs(environ['QUERY_STRING'])
 now = int(round(time.time()*1000000))
 n=d.get('t1',[''])[0]
 i=1
 p=1
 s=0
 while (i<=int(n)):
  p = p*i
  s =s+p
  i = i+1 
 end= int(round(time.time()*1000000))
 diff=end-now
 status = '200 OK'
 output = html % (s or 'Empty',now or 'Empty',end or 'Empty',diff or 'Empty') 

 response_headers = [('Content-type', 'text/html'),
                    ('Content-Length', str(len(output)))]
 start_response(status, response_headers)

 return [output]

and the output it shows is if i entered a number 4:

Result:33
Now:1346520500489000
End:1346520500489000
Time:Empty

wat else can i use to find out the time elapsed?

  • 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-10T14:22:30+00:00Added an answer on June 10, 2026 at 2:22 pm

    time.time() does not have infinite resolution — the operation that you’re testing takes next to no time at all. Try using a much larger n, or repeating the loop a large fixed number of times (e.g, a thousand) and dividing the result by the number of times you repeated it.

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

Sidebar

Related Questions

I hav used uigraphics cgcontext to draw line on touch...but my line is not
I have the following code that is used to switch background images on different
hi i hav a code like this in the end i m getting error
If using subsonic, i know you hav to close a datareader. but what if
I am testing Security environnement within Symfony2 and hav problem with log out process
I hav desgined a form of personal information for my website but the input
I have django tinymce setup but I hav noticed an issue with the tool
i hav a piece of code in which i have been comparing 2D and
I hav a table with following fields public class ActivationCode { public virtual int
I hav a code where Include method contains lowerd name of navigation property (Include(descriptions)

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.