Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
阿啄debugIT
transmittable-thread-local
提交
1a3b634e
T
transmittable-thread-local
项目概览
阿啄debugIT
/
transmittable-thread-local
与 Fork 源项目一致
从无法访问的项目Fork
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
transmittable-thread-local
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
1a3b634e
编写于
6月 17, 2018
作者:
oldratlee
🔥
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
convert Utils.java -> Utils.kt
上级
234d2402
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
35 addition
and
42 deletion
+35
-42
src/test/java/com/alibaba/ttl/perf/Utils.java
src/test/java/com/alibaba/ttl/perf/Utils.java
+0
-32
src/test/java/com/alibaba/ttl/perf/Utils.kt
src/test/java/com/alibaba/ttl/perf/Utils.kt
+25
-0
src/test/java/com/alibaba/ttl/perf/memoryleak/NoMemoryLeak_ThreadLocal_NoRemove.kt
.../ttl/perf/memoryleak/NoMemoryLeak_ThreadLocal_NoRemove.kt
+2
-2
src/test/java/com/alibaba/ttl/perf/memoryleak/NoMemoryLeak_TransmittableThreadLocal_NoRemove.kt
...oryleak/NoMemoryLeak_TransmittableThreadLocal_NoRemove.kt
+2
-2
src/test/java/com/alibaba/ttl/perf/tps/CreateThreadLocalInstanceTps.kt
.../com/alibaba/ttl/perf/tps/CreateThreadLocalInstanceTps.kt
+2
-2
src/test/java/com/alibaba/ttl/perf/tps/CreateTransmittableThreadLocalInstanceTps.kt
...ttl/perf/tps/CreateTransmittableThreadLocalInstanceTps.kt
+2
-2
src/test/java/com/alibaba/ttl/perf/tps/TpsCounter.kt
src/test/java/com/alibaba/ttl/perf/tps/TpsCounter.kt
+1
-2
src/test/java/com/alibaba/ttl/user_api_test/TransmittableThreadLocal_Transmitter_UserTest.kt
...api_test/TransmittableThreadLocal_Transmitter_UserTest.kt
+1
-0
未找到文件。
src/test/java/com/alibaba/ttl/perf/Utils.java
已删除
100644 → 0
浏览文件 @
234d2402
package
com.alibaba.ttl.perf
;
import
java.util.Random
;
/**
* @author Jerry Lee (oldratlee at gmail dot com)
*/
public
class
Utils
{
private
static
Random
random
=
new
Random
();
private
static
String
bytes2Hex
(
byte
[]
bytes
)
{
StringBuilder
sb
=
new
StringBuilder
(
1024
);
for
(
byte
b
:
bytes
)
{
String
s
=
Integer
.
toHexString
(
b
&
0xFF
);
sb
.
append
((
s
.
length
()
==
1
)
?
"0"
+
s
:
s
);
}
return
sb
.
toString
();
}
private
static
byte
[]
getRandomBytes
()
{
byte
[]
bytes
=
new
byte
[
1024
];
random
.
nextBytes
(
bytes
);
return
bytes
;
}
public
static
String
getRandomString
()
{
return
bytes2Hex
(
getRandomBytes
());
}
private
Utils
()
{
}
}
src/test/java/com/alibaba/ttl/perf/Utils.kt
0 → 100644
浏览文件 @
1a3b634e
package
com.alibaba.ttl.perf
import
java.util.*
private
val
random
=
Random
()
internal
fun
bytes2Hex
(
bytes
:
ByteArray
):
String
{
val
sb
=
StringBuilder
(
1024
)
for
(
b
in
bytes
)
{
val
s
=
Integer
.
toHexString
(
b
.
toInt
()
and
0xFF
)
sb
.
append
(
if
(
s
.
length
==
1
)
"0$s"
else
s
)
}
return
sb
.
toString
()
}
internal
fun
getRandomBytes
():
ByteArray
{
val
bytes
=
ByteArray
(
1024
)
random
.
nextBytes
(
bytes
)
return
bytes
}
internal
fun
getRandomString
():
String
{
return
bytes2Hex
(
getRandomBytes
())
}
src/test/java/com/alibaba/ttl/perf/memoryleak/NoMemoryLeak_ThreadLocal_NoRemove.kt
浏览文件 @
1a3b634e
...
...
@@ -2,7 +2,7 @@
package
com.alibaba.ttl.perf.memoryleak
import
com.alibaba.ttl.perf.
Utils
import
com.alibaba.ttl.perf.
getRandomString
/**
* @author Jerry Lee (oldratlee at gmail dot com)
...
...
@@ -11,7 +11,7 @@ fun main(args: Array<String>) {
var
counter
:
Long
=
0
while
(
true
)
{
val
threadLocal
=
ThreadLocal
<
String
>()
threadLocal
.
set
(
Utils
.
getRandomString
())
threadLocal
.
set
(
getRandomString
())
if
(
counter
%
1000
==
0L
)
System
.
out
.
printf
(
"%05dK%n"
,
counter
/
1000
)
...
...
src/test/java/com/alibaba/ttl/perf/memoryleak/NoMemoryLeak_TransmittableThreadLocal_NoRemove.kt
浏览文件 @
1a3b634e
...
...
@@ -3,7 +3,7 @@
package
com.alibaba.ttl.perf.memoryleak
import
com.alibaba.ttl.TransmittableThreadLocal
import
com.alibaba.ttl.perf.
Utils
import
com.alibaba.ttl.perf.
getRandomString
/**
* @author Jerry Lee (oldratlee at gmail dot com)
...
...
@@ -12,7 +12,7 @@ fun main(args: Array<String>) {
var
counter
:
Long
=
0
while
(
true
)
{
val
threadLocal
=
TransmittableThreadLocal
<
String
>()
threadLocal
.
set
(
Utils
.
getRandomString
())
threadLocal
.
set
(
getRandomString
())
if
(
counter
%
1000
==
0L
)
System
.
out
.
printf
(
"%05dK%n"
,
counter
/
1000
)
...
...
src/test/java/com/alibaba/ttl/perf/tps/CreateThreadLocalInstanceTps.kt
浏览文件 @
1a3b634e
...
...
@@ -2,7 +2,7 @@
package
com.alibaba.ttl.perf.tps
import
com.alibaba.ttl.perf.
Utils
import
com.alibaba.ttl.perf.
getRandomString
/**
* @author Jerry Lee (oldratlee at gmail dot com)
...
...
@@ -12,7 +12,7 @@ fun main(args: Array<String>) {
tpsCounter
.
setAction
(
Runnable
{
val
threadLocal
=
ThreadLocal
<
String
>()
threadLocal
.
set
(
Utils
.
getRandomString
())
threadLocal
.
set
(
getRandomString
())
})
while
(
true
)
{
...
...
src/test/java/com/alibaba/ttl/perf/tps/CreateTransmittableThreadLocalInstanceTps.kt
浏览文件 @
1a3b634e
...
...
@@ -3,7 +3,7 @@
package
com.alibaba.ttl.perf.tps
import
com.alibaba.ttl.TransmittableThreadLocal
import
com.alibaba.ttl.perf.
Utils
import
com.alibaba.ttl.perf.
getRandomString
/**
* @author Jerry Lee (oldratlee at gmail dot com)
...
...
@@ -13,7 +13,7 @@ fun main(args: Array<String>) {
tpsCounter
.
setAction
(
Runnable
{
val
threadLocal
=
TransmittableThreadLocal
<
String
>()
threadLocal
.
set
(
Utils
.
getRandomString
())
threadLocal
.
set
(
getRandomString
())
})
while
(
true
)
{
...
...
src/test/java/com/alibaba/ttl/perf/tps/TpsCounter.kt
浏览文件 @
1a3b634e
package
com.alibaba.ttl.perf.tps
import
org.junit.Assert.fail
import
java.util.concurrent.ExecutorService
import
java.util.concurrent.Executors
import
java.util.concurrent.TimeUnit
import
java.util.concurrent.atomic.AtomicLong
import
org.junit.Assert.fail
/**
* @author Jerry Lee (oldratlee at gmail dot com)
*/
...
...
src/test/java/com/alibaba/ttl/user_api_test/TransmittableThreadLocal_Transmitter_UserTest.kt
浏览文件 @
1a3b634e
...
...
@@ -108,6 +108,7 @@ class TransmittableThreadLocal_Transmitter_UserTest {
}
@AfterClass
@Suppress
(
"unused"
)
fun
afterClass
()
{
executorService
.
shutdown
()
executorService
.
awaitTermination
(
100
,
TimeUnit
.
MILLISECONDS
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录