aboutsummaryrefslogtreecommitdiff
path: root/tests/performance/00_bitset2.sy
diff options
context:
space:
mode:
authorRichard Qin <richard.qin.001@gmail.com>2026-09-15 08:16:43 +0800
committerRichard Qin <richard.qin.001@gmail.com>2026-09-15 08:16:43 +0800
commit4022e5c95210631e4aceb08eaf9d9071aa5aefc4 (patch)
treea5922559836e45fb3459a3d070367912e1035b1a /tests/performance/00_bitset2.sy
downloadrcc-master.tar.gz
rcc-master.tar.xz
Set up a git repoHEADmaster
Diffstat (limited to 'tests/performance/00_bitset2.sy')
-rw-r--r--tests/performance/00_bitset2.sy67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/performance/00_bitset2.sy b/tests/performance/00_bitset2.sy
new file mode 100644
index 0000000..b8b9e83
--- /dev/null
+++ b/tests/performance/00_bitset2.sy
@@ -0,0 +1,67 @@
+int set(int a[], int pos, int d){
+ const int bitcount = 30;
+ int x[bitcount + 1] = {};
+
+ x[0] = 1;
+ x[1] = x[0] * 2;
+ x[2] = x[1] * 2;
+ x[3] = x[2] * 2;
+ x[4] = x[3] * 2;
+ x[5] = x[4] * 2;
+ x[6] = x[5] * 2;
+ x[7] = x[6] * 2;
+ x[8] = x[7] * 2;
+ x[9] = x[8] * 2;
+ x[10] = x[9] * 2;
+
+ int i = 10;
+ while (i < bitcount){
+ i = i + 1;
+ x[i] = x[i - 1] * 2;
+ }
+
+ int v = 0;
+
+ if (pos / bitcount >= 10000) return 0;
+
+ if (a[pos / bitcount] / (x[pos % bitcount]) % 2 != d){
+ if (a[pos / bitcount] / (x[pos % bitcount]) % 2 == 0)
+ if (d == 1)
+ v = x[pos % bitcount];
+
+ if (a[pos / bitcount] / x[pos % bitcount] % 2 == 1)
+ if (d == 0)
+ v = v - x[pos % bitcount];
+ }
+
+ a[pos / bitcount] = a[pos / bitcount] + v;
+ return 0;
+}
+
+int seed[3] = {19971231, 19981013, 1000000000 + 7};
+int staticvalue = 0;
+
+int rand(){
+ staticvalue = staticvalue * seed[0] + seed[1];
+ staticvalue = staticvalue % seed[2];
+ if (staticvalue < 0) staticvalue = seed[2] + staticvalue;
+ return staticvalue;
+}
+
+int a[10000] = {};
+int main(){
+
+ int n = getint();
+ staticvalue = getint();
+ starttime();
+ int x, y;
+ while (n > 0){
+ n = n - 1;
+ x = rand() % 300000;
+ y = rand() % 2;
+ set(a, x, y);
+ }
+ stoptime();
+ putarray(10000, a);
+ return 0;
+} \ No newline at end of file