Template
Compare commits
9
Commits
f4dd2a5c08
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7a872252a | ||
|
|
de9e0a3357 | ||
|
|
746b9b7219 | ||
|
|
1f3fba80ec | ||
|
|
1d363980f6 | ||
|
|
4ce3a6aac0
|
||
|
|
c325131503 | ||
|
|
6f7c21e179 | ||
|
|
0e13d1035e |
No files matched your search
+62
@@ -0,0 +1,62 @@
|
|||||||
|
# ---> C
|
||||||
|
# Prerequisites
|
||||||
|
*.d
|
||||||
|
|
||||||
|
# Object files
|
||||||
|
*.o
|
||||||
|
*.ko
|
||||||
|
*.obj
|
||||||
|
*.elf
|
||||||
|
|
||||||
|
# Linker output
|
||||||
|
*.ilk
|
||||||
|
*.map
|
||||||
|
*.exp
|
||||||
|
|
||||||
|
# Precompiled Headers
|
||||||
|
*.gch
|
||||||
|
*.pch
|
||||||
|
|
||||||
|
# Libraries
|
||||||
|
*.lib
|
||||||
|
*.la
|
||||||
|
*.lo
|
||||||
|
|
||||||
|
# Shared objects (inc. Windows DLLs)
|
||||||
|
*.dll
|
||||||
|
*.so
|
||||||
|
*.so.*
|
||||||
|
*.dylib
|
||||||
|
|
||||||
|
# Executables
|
||||||
|
*.exe
|
||||||
|
*.out
|
||||||
|
*.app
|
||||||
|
*.i*86
|
||||||
|
*.x86_64
|
||||||
|
*.hex
|
||||||
|
Startcode/doble_initial
|
||||||
|
Startcode/doble
|
||||||
|
Startcode/unitTests
|
||||||
|
|
||||||
|
# Debug files
|
||||||
|
*.dSYM/
|
||||||
|
*.su
|
||||||
|
*.idb
|
||||||
|
*.pdb
|
||||||
|
|
||||||
|
# Kernel Module Compile Results
|
||||||
|
*.mod*
|
||||||
|
*.cmd
|
||||||
|
.tmp_versions/
|
||||||
|
modules.order
|
||||||
|
Module.symvers
|
||||||
|
Mkfile.old
|
||||||
|
dkms.conf
|
||||||
|
|
||||||
|
# IDE folders
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# macOS
|
||||||
|
.DS_Store
|
||||||
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
@@ -29,7 +29,7 @@ program_obj_files = stack.o bintree.o numbers.o timer.o highscore.o
|
|||||||
doble : main.o $(program_obj_files)
|
doble : main.o $(program_obj_files)
|
||||||
$(CC) $(FLAGS) $^ -o doble
|
$(CC) $(FLAGS) $^ -o doble
|
||||||
|
|
||||||
$(program_obj_filesobj_files): %.o: %.c
|
$(program_obj_files): %.o: %.c
|
||||||
$(CC) -c $(FLAGS) $^ -o $@
|
$(CC) -c $(FLAGS) $^ -o $@
|
||||||
|
|
||||||
# --------------------------
|
# --------------------------
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,55 @@
|
|||||||
|
#include "timer.h"
|
||||||
|
|
||||||
|
#if __APPLE__
|
||||||
|
#include <sys/time.h>
|
||||||
|
static struct timespec start = {0, 0};
|
||||||
|
|
||||||
|
// Starts the timer.
|
||||||
|
void startTimer()
|
||||||
|
{
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the time in seconds since startTimer() was called.
|
||||||
|
double stopTimer()
|
||||||
|
{
|
||||||
|
struct timespec end;
|
||||||
|
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &end);
|
||||||
|
|
||||||
|
unsigned long long delta_us = (end.tv_sec - start.tv_sec) * 1000000 + (end.tv_nsec - start.tv_nsec) / 1000;
|
||||||
|
|
||||||
|
double measuredSeconds = (double)delta_us / 1000000.;
|
||||||
|
|
||||||
|
if(start.tv_nsec > 0) {
|
||||||
|
start.tv_nsec = 0;
|
||||||
|
start.tv_sec = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
measuredSeconds = -1;
|
||||||
|
|
||||||
|
return measuredSeconds;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#include <time.h>
|
||||||
|
static clock_t startClocks = 0;
|
||||||
|
|
||||||
|
// Starts the timer.
|
||||||
|
void startTimer()
|
||||||
|
{
|
||||||
|
startClocks = clock();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the time in seconds since startTimer() was called.
|
||||||
|
double stopTimer()
|
||||||
|
{
|
||||||
|
double measuredSeconds = (clock() - (double)startClocks) / CLOCKS_PER_SEC;
|
||||||
|
|
||||||
|
if(startClocks > 0)
|
||||||
|
startClocks = 0;
|
||||||
|
else
|
||||||
|
measuredSeconds = -1;
|
||||||
|
|
||||||
|
return measuredSeconds;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
@@ -1,23 +0,0 @@
|
|||||||
#include <time.h>
|
|
||||||
#include "timer.h"
|
|
||||||
|
|
||||||
static clock_t startClocks = 0;
|
|
||||||
|
|
||||||
// Starts the timer.
|
|
||||||
void startTimer()
|
|
||||||
{
|
|
||||||
startClocks = clock();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the time in seconds since startTimer() was called.
|
|
||||||
double stopTimer()
|
|
||||||
{
|
|
||||||
double measuredSeconds = (clock() - (double)startClocks) / CLOCKS_PER_SEC;
|
|
||||||
|
|
||||||
if(startClocks > 0)
|
|
||||||
startClocks = 0;
|
|
||||||
else
|
|
||||||
measuredSeconds = -1;
|
|
||||||
|
|
||||||
return measuredSeconds;
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user