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