Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
ff221092
提交
ff221092
authored
8 年前
作者:
Ulrich Wielant
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename some variables to point out usage of nanoseconds time stamp
上级
f3a1598b
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
36 行增加
和
36 行删除
+36
-36
Sentence.java
h2/src/main/org/h2/bnf/Sentence.java
+3
-3
Optimizer.java
h2/src/main/org/h2/command/dml/Optimizer.java
+3
-3
Session.java
h2/src/main/org/h2/engine/Session.java
+8
-8
Console.java
h2/src/main/org/h2/tools/Console.java
+3
-3
StringUtils.java
h2/src/main/org/h2/util/StringUtils.java
+3
-3
ShowProgress.java
h2/src/test/org/h2/samples/ShowProgress.java
+7
-7
Database.java
h2/src/test/org/h2/test/bench/Database.java
+3
-3
Profile.java
h2/src/test/org/h2/test/coverage/Profile.java
+6
-6
没有找到文件。
h2/src/main/org/h2/bnf/Sentence.java
浏览文件 @
ff221092
...
...
@@ -54,7 +54,7 @@ public class Sentence {
*/
private
String
queryUpper
;
private
long
stopAt
;
private
long
stopAt
Ns
;
private
DbSchema
lastMatchedSchema
;
private
DbTableOrView
lastMatchedTable
;
private
DbTableOrView
lastTable
;
...
...
@@ -65,7 +65,7 @@ public class Sentence {
* Start the timer to make sure processing doesn't take too long.
*/
public
void
start
()
{
stopAt
=
System
.
nanoTime
()
+
TimeUnit
.
MILLISECONDS
.
toNanos
(
MAX_PROCESSING_TIME
);
stopAt
Ns
=
System
.
nanoTime
()
+
TimeUnit
.
MILLISECONDS
.
toNanos
(
MAX_PROCESSING_TIME
);
}
/**
...
...
@@ -74,7 +74,7 @@ public class Sentence {
* If processing is stopped, this methods throws an IllegalStateException
*/
public
void
stopIfRequired
()
{
if
(
System
.
nanoTime
()
>
stopAt
)
{
if
(
System
.
nanoTime
()
>
stopAt
Ns
)
{
throw
new
IllegalStateException
();
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/command/dml/Optimizer.java
浏览文件 @
ff221092
...
...
@@ -25,7 +25,7 @@ class Optimizer {
private
static
final
int
MAX_BRUTE_FORCE_FILTERS
=
7
;
private
static
final
int
MAX_BRUTE_FORCE
=
2000
;
private
static
final
int
MAX_GENETIC
=
500
;
private
long
start
;
private
long
start
Ns
;
private
BitField
switched
;
// possible plans for filters, if using brute force:
...
...
@@ -80,7 +80,7 @@ class Optimizer {
if
(
filters
.
length
==
1
||
session
.
isForceJoinOrder
())
{
testPlan
(
filters
);
}
else
{
start
=
System
.
nanoTime
();
start
Ns
=
System
.
nanoTime
();
if
(
filters
.
length
<=
MAX_BRUTE_FORCE_FILTERS
)
{
calculateBruteForceAll
();
}
else
{
...
...
@@ -98,7 +98,7 @@ class Optimizer {
private
boolean
canStop
(
int
x
)
{
if
((
x
&
127
)
==
0
)
{
long
t
=
System
.
nanoTime
()
-
start
;
long
t
=
System
.
nanoTime
()
-
start
Ns
;
// don't calculate for simple queries (no rows or so)
if
(
cost
>=
0
&&
10
*
t
>
cost
*
TimeUnit
.
MILLISECONDS
.
toNanos
(
1
))
{
return
true
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/engine/Session.java
浏览文件 @
ff221092
...
...
@@ -102,7 +102,7 @@ public class Session extends SessionWithState {
private
boolean
redoLogBinary
=
true
;
private
boolean
autoCommitAtTransactionEnd
;
private
String
currentTransactionName
;
private
volatile
long
cancelAt
;
private
volatile
long
cancelAt
Ns
;
private
boolean
closed
;
private
final
long
sessionStart
=
System
.
currentTimeMillis
();
private
long
transactionStart
;
...
...
@@ -811,7 +811,7 @@ public class Session extends SessionWithState {
@Override
public
void
cancel
()
{
cancelAt
=
System
.
nanoTime
();
cancelAt
Ns
=
System
.
nanoTime
();
}
@Override
...
...
@@ -1181,7 +1181,7 @@ public class Session extends SessionWithState {
if
(
queryTimeout
>
0
&&
command
!=
null
)
{
currentCommandStart
=
System
.
currentTimeMillis
();
long
now
=
System
.
nanoTime
();
cancelAt
=
now
+
TimeUnit
.
MILLISECONDS
.
toNanos
(
queryTimeout
);
cancelAt
Ns
=
now
+
TimeUnit
.
MILLISECONDS
.
toNanos
(
queryTimeout
);
}
}
...
...
@@ -1193,12 +1193,12 @@ public class Session extends SessionWithState {
*/
public
void
checkCanceled
()
{
throttle
();
if
(
cancelAt
==
0
)
{
if
(
cancelAt
Ns
==
0
)
{
return
;
}
long
time
=
System
.
nanoTime
();
if
(
time
>=
cancelAt
)
{
cancelAt
=
0
;
if
(
time
>=
cancelAt
Ns
)
{
cancelAt
Ns
=
0
;
throw
DbException
.
get
(
ErrorCode
.
STATEMENT_WAS_CANCELED
);
}
}
...
...
@@ -1209,7 +1209,7 @@ public class Session extends SessionWithState {
* @return the time or 0 if not set
*/
public
long
getCancel
()
{
return
cancelAt
;
return
cancelAt
Ns
;
}
public
Command
getCurrentCommand
()
{
...
...
@@ -1500,7 +1500,7 @@ public class Session extends SessionWithState {
this
.
queryTimeout
=
queryTimeout
;
// must reset the cancel at here,
// otherwise it is still used
this
.
cancelAt
=
0
;
this
.
cancelAt
Ns
=
0
;
}
public
int
getQueryTimeout
()
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/tools/Console.java
浏览文件 @
ff221092
...
...
@@ -62,7 +62,7 @@ ShutdownHandler {
//*/
private
Server
web
,
tcp
,
pg
;
private
boolean
isWindows
;
private
long
lastOpen
;
private
long
lastOpen
Ns
;
/**
* When running without options, -tcp, -web, -browser and -pg are started.
...
...
@@ -535,8 +535,8 @@ ShutdownHandler {
urlText
.
setText
(
url
);
}
long
now
=
System
.
nanoTime
();
if
(
lastOpen
==
0
||
lastOpen
+
TimeUnit
.
MILLISECONDS
.
toNanos
(
100
)
<
now
)
{
lastOpen
=
now
;
if
(
lastOpen
Ns
==
0
||
lastOpenNs
+
TimeUnit
.
MILLISECONDS
.
toNanos
(
100
)
<
now
)
{
lastOpen
Ns
=
now
;
openBrowser
(
url
);
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/util/StringUtils.java
浏览文件 @
ff221092
...
...
@@ -23,7 +23,7 @@ public class StringUtils {
private
static
SoftReference
<
String
[]>
softCache
=
new
SoftReference
<
String
[]>(
null
);
private
static
long
softCacheCreated
;
private
static
long
softCacheCreated
Ns
;
private
static
final
char
[]
HEX
=
"0123456789abcdef"
.
toCharArray
();
private
static
final
int
[]
HEX_DECODE
=
new
int
[
'f'
+
1
];
...
...
@@ -64,7 +64,7 @@ public class StringUtils {
// create a new cache at most every 5 seconds
// so that out of memory exceptions are not delayed
long
time
=
System
.
nanoTime
();
if
(
softCacheCreated
!=
0
&&
time
-
softCacheCreated
<
TimeUnit
.
SECONDS
.
toNanos
(
5
))
{
if
(
softCacheCreated
Ns
!=
0
&&
time
-
softCacheCreatedNs
<
TimeUnit
.
SECONDS
.
toNanos
(
5
))
{
return
null
;
}
try
{
...
...
@@ -72,7 +72,7 @@ public class StringUtils {
softCache
=
new
SoftReference
<
String
[]>(
cache
);
return
cache
;
}
finally
{
softCacheCreated
=
System
.
nanoTime
();
softCacheCreated
Ns
=
System
.
nanoTime
();
}
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/samples/ShowProgress.java
浏览文件 @
ff221092
...
...
@@ -22,14 +22,14 @@ import org.h2.jdbc.JdbcConnection;
*/
public
class
ShowProgress
implements
DatabaseEventListener
{
private
final
long
start
;
private
long
last
;
private
final
long
start
Ns
;
private
long
last
Ns
;
/**
* Create a new instance of this class, and start the timer.
* Create a new instance of this class, and start
Ns
the timer.
*/
public
ShowProgress
()
{
start
=
last
=
System
.
nanoTime
();
start
Ns
=
lastNs
=
System
.
nanoTime
();
}
/**
...
...
@@ -114,10 +114,10 @@ public class ShowProgress implements DatabaseEventListener {
@Override
public
void
setProgress
(
int
state
,
String
name
,
int
current
,
int
max
)
{
long
time
=
System
.
nanoTime
();
if
(
time
<
last
+
TimeUnit
.
SECONDS
.
toNanos
(
5
))
{
if
(
time
<
last
Ns
+
TimeUnit
.
SECONDS
.
toNanos
(
5
))
{
return
;
}
last
=
time
;
last
Ns
=
time
;
String
stateName
=
"?"
;
switch
(
state
)
{
case
STATE_SCAN_FILE:
...
...
@@ -140,7 +140,7 @@ public class ShowProgress implements DatabaseEventListener {
System
.
out
.
println
(
"State: "
+
stateName
+
" "
+
(
100
*
current
/
max
)
+
"% ("
+
current
+
" of "
+
max
+
") "
+
TimeUnit
.
NANOSECONDS
.
toMillis
(
time
-
start
)
+
" ms"
);
+
TimeUnit
.
NANOSECONDS
.
toMillis
(
time
-
start
Ns
)
+
" ms"
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/bench/Database.java
浏览文件 @
ff221092
...
...
@@ -36,7 +36,7 @@ class Database {
private
String
name
,
url
,
user
,
password
;
private
final
ArrayList
<
String
[]>
replace
=
new
ArrayList
<
String
[]>();
private
String
currentAction
;
private
long
startTime
;
private
long
startTime
Ns
;
private
Connection
conn
;
private
Statement
stat
;
private
long
lastTrace
;
...
...
@@ -271,7 +271,7 @@ class Database {
*/
void
start
(
Bench
bench
,
String
action
)
{
this
.
currentAction
=
bench
.
getName
()
+
": "
+
action
;
this
.
startTime
=
System
.
nanoTime
();
this
.
startTime
Ns
=
System
.
nanoTime
();
}
/**
...
...
@@ -279,7 +279,7 @@ class Database {
* data.
*/
void
end
()
{
long
time
=
TimeUnit
.
NANOSECONDS
.
toMillis
(
System
.
nanoTime
()
-
startTime
);
long
time
=
TimeUnit
.
NANOSECONDS
.
toMillis
(
System
.
nanoTime
()
-
startTime
Ns
);
log
(
currentAction
,
"ms"
,
(
int
)
time
);
if
(
test
.
isCollect
())
{
totalTime
+=
time
;
...
...
This diff is collapsed.
Click to expand it.
h2/src/test/org/h2/test/coverage/Profile.java
浏览文件 @
ff221092
...
...
@@ -27,7 +27,7 @@ public class Profile extends Thread {
private
boolean
stop
;
private
int
maxIndex
;
private
int
lastIndex
;
private
long
lastTime
;
private
long
lastTime
Ns
;
private
BufferedWriter
trace
;
private
Profile
()
{
...
...
@@ -38,7 +38,7 @@ public class Profile extends Thread {
maxIndex
=
r
.
getLineNumber
();
count
=
new
int
[
maxIndex
];
time
=
new
int
[
maxIndex
];
lastTime
=
System
.
nanoTime
();
lastTime
Ns
=
System
.
nanoTime
();
Runtime
.
getRuntime
().
addShutdownHook
(
this
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -77,7 +77,7 @@ public class Profile extends Thread {
*/
public
static
void
startCollecting
()
{
MAIN
.
stop
=
false
;
MAIN
.
lastTime
=
System
.
nanoTime
();
MAIN
.
lastTime
Ns
=
System
.
nanoTime
();
}
/**
...
...
@@ -111,7 +111,7 @@ public class Profile extends Thread {
long
now
=
System
.
nanoTime
();
if
(
TRACE
)
{
if
(
trace
!=
null
)
{
int
duration
=
(
int
)
TimeUnit
.
NANOSECONDS
.
toMillis
(
now
-
lastTime
);
long
duration
=
TimeUnit
.
NANOSECONDS
.
toMillis
(
now
-
lastTimeNs
);
try
{
trace
.
write
(
i
+
"\t"
+
duration
+
"\r\n"
);
}
catch
(
Exception
e
)
{
...
...
@@ -121,8 +121,8 @@ public class Profile extends Thread {
}
}
count
[
i
]++;
time
[
lastIndex
]
+=
(
int
)
TimeUnit
.
NANOSECONDS
.
toMillis
(
now
-
lastTime
);
lastTime
=
now
;
time
[
lastIndex
]
+=
(
int
)
TimeUnit
.
NANOSECONDS
.
toMillis
(
now
-
lastTime
Ns
);
lastTime
Ns
=
now
;
lastIndex
=
i
;
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论