Skip to content
This repository was archived by the owner on Aug 18, 2025. It is now read-only.

Commit 90b44fc

Browse files
committed
新增比较和逻辑运算JIT编译测试,验证多种运算符和条件表达式的性能,进一步提升条件判断效率。
1 parent c49f54f commit 90b44fc

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed

comparison_logical_test.cn

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
// 🚀 CodeNothing v0.6.6 比较和逻辑运算JIT编译测试
2+
// 验证比较运算符、逻辑运算符和条件表达式的JIT编译功能
3+
4+
using lib <io>;
5+
using ns std;
6+
7+
fn main() : int {
8+
std::println("🚀 CodeNothing v0.6.6 比较和逻辑运算JIT编译测试");
9+
std::println("=====================================");
10+
11+
// 📊 测试1:比较运算符测试
12+
std::println("🔍 测试1:比较运算符JIT编译");
13+
a : int = 10;
14+
b : int = 20;
15+
c : int = 10;
16+
17+
// 等于比较
18+
equal_result : int = 0;
19+
for (i : 1..101) { // 100次迭代,触发JIT编译
20+
if (a == c) {
21+
equal_result = equal_result + 1;
22+
};
23+
};
24+
std::println("等于比较结果: " + equal_result);
25+
26+
// 不等于比较
27+
not_equal_result : int = 0;
28+
for (i : 1..101) { // 100次迭代
29+
if (a != b) {
30+
not_equal_result = not_equal_result + 1;
31+
};
32+
};
33+
std::println("不等于比较结果: " + not_equal_result);
34+
35+
// 小于比较
36+
less_result : int = 0;
37+
for (i : 1..101) { // 100次迭代
38+
if (a < b) {
39+
less_result = less_result + 1;
40+
};
41+
};
42+
std::println("小于比较结果: " + less_result);
43+
std::println("-------------------------------------");
44+
45+
// 📊 测试2:逻辑运算符测试
46+
std::println("🧠 测试2:逻辑运算符JIT编译");
47+
x : int = 5;
48+
y : int = 15;
49+
z : int = 25;
50+
51+
// 逻辑与测试
52+
and_result : int = 0;
53+
for (i : 1..101) { // 100次迭代
54+
if (x < y && y < z) {
55+
and_result = and_result + 1;
56+
};
57+
};
58+
std::println("逻辑与结果: " + and_result);
59+
60+
// 逻辑或测试
61+
or_result : int = 0;
62+
for (i : 1..101) { // 100次迭代
63+
if (x > y || y < z) {
64+
or_result = or_result + 1;
65+
};
66+
};
67+
std::println("逻辑或结果: " + or_result);
68+
std::println("-------------------------------------");
69+
70+
// 📊 测试3:复杂条件表达式测试
71+
std::println("🎯 测试3:复杂条件表达式JIT编译");
72+
p : int = 8;
73+
q : int = 12;
74+
r : int = 16;
75+
76+
// 复杂条件组合
77+
complex_result : int = 0;
78+
for (i : 1..101) { // 100次迭代
79+
if ((p < q && q < r) || (p > r)) {
80+
complex_result = complex_result + 1;
81+
};
82+
};
83+
std::println("复杂条件结果: " + complex_result);
84+
std::println("-------------------------------------");
85+
86+
// 📊 测试4:数值范围判断测试
87+
std::println("📊 测试4:数值范围判断优化");
88+
range_count : int = 0;
89+
for (i : 1..201) { // 200次迭代
90+
if (i >= 50 && i <= 150) {
91+
range_count = range_count + 1;
92+
};
93+
};
94+
std::println("范围内数值个数: " + range_count);
95+
std::println("-------------------------------------");
96+
97+
// 📊 测试5:条件计数器测试
98+
std::println("🔢 测试5:条件计数器优化");
99+
even_count : int = 0;
100+
odd_count : int = 0;
101+
for (i : 1..101) { // 100次迭代
102+
if (i % 2 == 0) {
103+
even_count = even_count + 1;
104+
};
105+
if (i % 2 != 0) {
106+
odd_count = odd_count + 1;
107+
};
108+
};
109+
std::println("偶数个数: " + even_count);
110+
std::println("奇数个数: " + odd_count);
111+
std::println("-------------------------------------");
112+
113+
// 📊 测试6:嵌套条件判断测试
114+
std::println("🎨 测试6:嵌套条件判断优化");
115+
nested_result : int = 0;
116+
for (i : 1..101) { // 100次迭代
117+
if (i > 25) {
118+
if (i < 75) {
119+
if (i % 3 == 0) {
120+
nested_result = nested_result + 1;
121+
};
122+
};
123+
};
124+
};
125+
std::println("嵌套条件结果: " + nested_result);
126+
std::println("=====================================");
127+
128+
std::println("🎉 比较和逻辑运算JIT编译测试完成!");
129+
std::println("请查看JIT统计信息验证编译效果");
130+
131+
return 0;
132+
};

0 commit comments

Comments
 (0)