计算完成一项任务花费的时间 [英] Calculate how much time taken to complete a task

查看:139
本文介绍了计算完成一项任务花费的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我将通过询问几个问题来评估学生.单击开始"按钮后,我想计算出学生回答这些问题所花费的时间.

开始评估时应该分配固定的时间,并且花在回答问题上的时间应减少(减少)

我要显示的是:-
-单击开始"按钮后要花费多少时间
-剩余时间超出固定时间

Hi
I am going to evaluate a student by asking few questions.After clicks Start button I want to calculate how much time taken to answer these questions by the student.

there should be a fixed time allocated when starting the evaluation and it should be reduced(decrease)when time spending to answer the questions

what i want to display is :-
- how much time consume after clicking the start button
- Remaining time out of fixed time

推荐答案

使用DateTime.现在知道它们开始的时间.然后,您可以定期触发一个计时器,并从DateTime中减去您的存储值.现在,找出经过了几秒钟.
Use DateTime.Now to know the time they started. Then you can fire a timer regularly and subtract your stored value from DateTime.Now to find out how many seconds have passed.


要计算还是要测量?我认为-要衡量.

比System.DateTime更准确的是类System.Diagnostics.Stopwatch:
http://msdn.microsoft.com/en-us/library/system.diagnostics. stopwatch.aspx [ ^ ].

这是衡量性能和相关时间间隔值的最佳方法.类文档充分描述了用法和功能.

—SA
To calculate or just to measure? I think — to measure.

More accurate than System.DateTime is the class System.Diagnostics.Stopwatch:
http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch.aspx[^].

This is the best way to measure performance and related time interval values. The class documentation fully describes the use and the features.

—SA


基本上,您只需要存储几条信息
  • 此人开始回答问题的时间
  • 给出回答问题的固定时间
Well basically you need to store just few pieces of information
  • The time the person started to answer questions
  • The fixed amount of time that''s given to answer the question


这篇关于计算完成一项任务花费的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆