This reverts commit 34344982a9
.
This commit is contained in:
30
programs/bpf/c/src/bench_alu/bench_alu.c
Normal file
30
programs/bpf/c/src/bench_alu/bench_alu.c
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @brief Benchmark program that does work
|
||||
*
|
||||
* Counts Armstrong Numbers between 1 and x
|
||||
*/
|
||||
|
||||
#include <solana_sdk.h>
|
||||
|
||||
extern bool entrypoint(const uint8_t *input) {
|
||||
uint64_t x = *(uint64_t *) input;
|
||||
uint64_t *result = (uint64_t *) input + 1;
|
||||
uint64_t count = 0;
|
||||
|
||||
for (int i = 1; i <= x; i++) {
|
||||
uint64_t temp = i;
|
||||
uint64_t num = 0;
|
||||
while (temp != 0) {
|
||||
uint64_t rem = (temp % 10);
|
||||
num += rem * rem * rem;
|
||||
temp /= 10;
|
||||
}
|
||||
if (i == num) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
sol_log_64(x, count, 0, 0, 0);
|
||||
*result = count;
|
||||
return true;
|
||||
}
|
Reference in New Issue
Block a user