-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transplant jmh test Ring.java from Loom #127
base: KonaFiber
Are you sure you want to change the base?
Conversation
@HangerLIN |
demo/fiber/Ring_test/pom.xml
Outdated
<dependency> | ||
<groupId>org.openjdk.jmh</groupId> | ||
<artifactId>jmh-core</artifactId> | ||
<version>1.23</version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version 1.37 may be better.
@@ -0,0 +1,171 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
老师我不知道,我为什么把下面的那个您给出的对Worker泛型需要进行修改,的那部分的意见给点掉了。我理解您意思是想要把 workers = new Worker[chans.length - 1];
这样的代码修改成 List<Worker<Integer>> workers = new ArrayList<>(chans.size() - 1);
这样的代码。但是我在使用前者,也就是loom原本给出来的形式去运行的时候,并没有报错?那我是否还需要修改呢?
|
||
|
||
public static void main(String[] args) throws RunnerException { | ||
Options opt = new OptionsBuilder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
缩进看不来不太对,是不是把空格转化成tab了?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的,这好像是我现在写代码的习惯,一般是怎么用空格的来着?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loom原始文件是什么样,这里就应该是什么样。
另外,你需要在comment里加一个git diff,列一下你和loom原始文件的差异
} | ||
|
||
|
||
public static void main(String[] args) throws RunnerException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么要加这个main函数?
|
||
private void startAll() { | ||
for (Worker<Integer> w : workers) { | ||
Thread.ofVirtual().scheduler(Executors.newSingleThreadExecutor()).start(w); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里为什么要改? Kona Fiber也有startVirtualThread这个接口
而且即使改,为什么要改成单线程的调度器?
How to Run the Test <dependencies>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>1.37</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>1.37</version>
</dependency>
</dependencies> Altered the Method for Starting Workers: In the Loom version, the getChannel() method used the enhanced switch expression syntax:
Here is the git diff between the original one and the version I made it adapted to Kona.
|
我已经修改了描述文档,请老师过目 |
我只是确定一下,上面的 |
我是把原本在终端栏的全部信息都复制上来了 |
是不是一屏幕不能显示出全部内容? |
按照和老师会议谈论内容增加了Ring.java以及 Channel.java的实现逻辑和结果 |
<maven.compiler.target>8</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
</project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
缺少一个换行。
How to Run the Test
mvn clean package
to build the project.org.example.Ring
to start the test.res.json
changes:
Add jmh dependencies in pom.xml
Altered the Method for Starting Workers:
startAll()
method was usingThread.startVirtualThread(w);
to start virtual threads.Thread.ofVirtual().scheduler(Executors.newSingleThreadExecutor()).start(w);
to start the virtual threads as well.Modified Channel Creation:
getChannel()
method used the enhanced switch expression syntax: