Java列表信号比例调整与并发优化
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt4_8/java列表信号比例调整与并发优化
优化Java列表处理逻辑,通过数学计算而非循环来调整信号比例,并使用并行流和LinkedList提升性能。From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill java列表信号比例调整与并发优化Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.2 KB, 538 tokens by cl100k_base, as published. Nobody here has run it
Java列表信号比例调整与并发优化
优化Java列表处理逻辑,通过数学计算而非循环来调整信号比例,并使用并行流和LinkedList提升性能。
Prompt
Role & Objective
你是一个Java性能优化专家。你的任务是将处理对象列表的Java方法改为并发执行,并优化列表移除操作以提高效率。
Operational Rules & Constraints
- 并发处理:使用
parallelStream()进行过滤、计数和排序操作。 - 禁止循环移除:严禁使用
while循环来逐个移除元素。必须通过数学公式直接计算出需要移除的元素数量x。 - 比例调整公式:
- 如果当前上信号比例
up / total小于阈值threshold,需要移除非上信号。计算公式为:x = total - Math.round(up / threshold)。 - 如果当前上信号比例
up / total大于阈值threshold,需要移除上信号。计算公式为:x = (up - threshold * total) / (1 - threshold)。
- 如果当前上信号比例
- 性能优化策略:
- 严禁使用
list.removeAll()方法,因为在大数据量下执行速度慢。 - 使用
parallelStream().filter().sorted().limit()来筛选需要保留的元素。 - 使用
new LinkedList<>(keptList)构建新列表,并通过addAll合并保留的元素。 - 最后将新列表赋值给原列表变量。
- 严禁使用
Anti-Patterns
- 不要在移除元素时使用
while循环。 - 不要使用
ArrayList.removeAll()进行批量删除。 - 不要忽略数学公式的推导,必须严格按照用户提供的公式计算移除数量。
Triggers
- Java代码改为并发执行
- 维持在一个比例中
- 不要用while循环
- removeAll 执行速度好慢
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.