12345678910111213141516171819202122232425262728293031323334353637 |
- #include <stdio.h>
- #include <string.h>
- #include <time.h>
- #include "Compiler.h"
- #include "Script.h"
- #include "Test.h"
- #include "tokenizer/Tokenizer.h"
- long getNanos() {
- struct timespec time;
- clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time);
- return time.tv_nsec + time.tv_sec * 1000000000l;
- }
- int main(int argAmount, const char** args) {
- if(argAmount >= 3 && strcmp(args[1], "test") == 0) {
- tsStart(args[2]);
- } else if(argAmount >= 2) {
- if(tTokenize(args[1])) {
- puts(tGetError());
- return 0;
- }
- ByteCode* code = cCompile();
- if(code == NULL) {
- puts(tGetError());
- return 0;
- }
- Script* sc = sInit(code);
- long time = -getNanos();
- sRun(sc);
- time += getNanos();
- printf("----------------\n%ld ns\n", time);
- sDelete(sc);
- }
- return 0;
- }
|