Menu

[r2]: / dbpool / TimeCostTimer.java  Maximize  Restore  History

Download this file

54 lines (44 with data), 762 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
*
*/
package com.handjoys.dbpool;
/**
* <b>记录查询时间的计时器</b>
* @author 汉娱网络.技术部.wanggl
* @since 1.1
*/
public class TimeCostTimer {
private long timeCostBegin=0L;
private long timeCostEnd=0L;
/**
* <b>记录时间开始</b>
*/
public void start()
{
timeCostBegin=System.currentTimeMillis();
timeCostEnd=0L;
}
/**
* <b>记录时间结束</b>
*/
public void stop()
{
timeCostEnd=System.currentTimeMillis();
}
/**
* <b>获取执行的时间,单位为秒</b>
* <>
* @return
*/
public double getTimeCost()
{
if(timeCostBegin<timeCostEnd)
{
return (timeCostEnd-timeCostBegin)/1000.0;
}
else
{
return 0.0;
}
}
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.