Add BPF benchmarks

This commit is contained in:
jackcmay
2018-11-14 12:06:06 -08:00
committed by GitHub
parent 2ad2fdd235
commit 39c87fd103
7 changed files with 181 additions and 25 deletions

View File

@ -0,0 +1,27 @@
/**
* @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 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++;
}
}
return count;
}