Skip to content

Instantly share code, notes, and snippets.

@0xjac
Created September 23, 2016 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xjac/35552902898c5546372becbfdad7c6c4 to your computer and use it in GitHub Desktop.
Save 0xjac/35552902898c5546372becbfdad7c6c4 to your computer and use it in GitHub Desktop.
FLOPS
#!/usr/bin/env bash
FLOP=4000000;
gcc -o main main.c;
TIMEFORMAT=%R
ELAPSED=`( time ./main ) 2>&1 > /dev/null`
FLOPS=$(echo "$FLOP/$ELAPSED" | bc)
echo "elapsed: $ELAPSED seconds"
echo "flops: $FLOPS"
#define NUMBERS 1000000
int main(void) {
float values[NUMBERS];
float res;
int i, j=3, k=42;
for(i=0; i < NUMBERS; i++) {
values[i] = (i + k) * j;
res = values[i] / (float)k;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment