L
This commit is contained in:
Binary file not shown.
+43
-28
@@ -15,12 +15,19 @@ int main(int argc,char **argv) {
|
||||
case '2': // Test Sorts
|
||||
{
|
||||
int n;
|
||||
if(!(argv[1][1]>='a'&&argv[1][1]<='z')) return 0;
|
||||
if(!(argv[1][1]>='a'&&argv[1][1]<='z')){
|
||||
printf("\nPrint 2(r/h/b/m) to sort or 3 to see var");
|
||||
printf("\n2r - radix\n2h - heap\n2b - bubble\n2m - merge\n");
|
||||
return 0;}
|
||||
printf("Write n:");
|
||||
scanf("%d",&n);
|
||||
while(getchar()>'\n');
|
||||
uint32_t *arr = (uint32_t*)malloc(sizeof(uint32_t) * n);
|
||||
fill_rand(arr, n);
|
||||
printf("Write n nums:");
|
||||
for (int i = 0;i<n;i++){
|
||||
scanf("%d",&arr[i]);
|
||||
}
|
||||
|
||||
for(int i = 0; i<n;i++)printf("%d ",arr[i]);
|
||||
putchar('\n');
|
||||
|
||||
@@ -42,17 +49,24 @@ int main(int argc,char **argv) {
|
||||
for(int i = 0; i<n;i++)printf("%d ",arr[i]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
printf("\nPrint 2(r/h/b/m) to sort or 3 to see var");
|
||||
printf("\n2r - radix\n2h - heap\n2b - bubble\n2m - merge\n");
|
||||
return 0;
|
||||
}
|
||||
free(arr);
|
||||
break;
|
||||
}
|
||||
case '3':
|
||||
{
|
||||
printf("\n N - %d",(18-1)%24+1);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
printf("\nPrint 2(r/h/b/m) to sort or 3 to see var");
|
||||
printf("\n2r - radix\n2h - heap\n2b - bubble\n2m - merge\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
@@ -71,37 +85,38 @@ void run_exp(void) {
|
||||
int n = MILLION,end=MILLION,step = 50000;
|
||||
for (;n<=end;n+=step){
|
||||
|
||||
uint32_t *arr = (uint32_t*)malloc(sizeof(uint32_t) * n);
|
||||
uint32_t *arrA = (uint32_t*)malloc(sizeof(uint32_t) * n);
|
||||
uint32_t *arrB = (uint32_t*)malloc(sizeof(uint32_t) * n);
|
||||
uint32_t *arrC = (uint32_t*)malloc(sizeof(uint32_t) * n);
|
||||
|
||||
double tRadTotal = 0;
|
||||
for (int i = 0; i < AVG_TIME_LOOPS; i++) {
|
||||
fill_rand(arr, n);
|
||||
double t = get_time();
|
||||
sort_radix(arr,n);
|
||||
tRadTotal += (get_time() - t);
|
||||
}
|
||||
double tRadRes = tRadTotal / AVG_TIME_LOOPS;
|
||||
|
||||
double tHeapTotal = 0;
|
||||
for (int i = 0; i < AVG_TIME_LOOPS; i++) {
|
||||
fill_rand(arr, n);
|
||||
double t = get_time();
|
||||
sort_heap(arr, n);
|
||||
tHeapTotal += (get_time() - t);
|
||||
}
|
||||
double tHeapRes = tHeapTotal / AVG_TIME_LOOPS;
|
||||
|
||||
double tBubblTotal = 0;
|
||||
for (int i = 0; i < AVG_TIME_LOOPS; i++) {
|
||||
fill_rand(arr, n);
|
||||
double t = get_time();
|
||||
sort_bubble(arr,n);
|
||||
tBubblTotal += (get_time() - t);
|
||||
fill_rand(arrA, n);
|
||||
arrC = arrB = arrA;
|
||||
|
||||
double ta = get_time();
|
||||
sort_radix(arrA,n);
|
||||
tRadTotal += (get_time() - ta);
|
||||
|
||||
double tb = get_time();
|
||||
sort_heap(arrB, n);
|
||||
tHeapTotal += (get_time() - tb);
|
||||
|
||||
double tc = get_time();
|
||||
sort_bubble(arrC,n);
|
||||
tBubblTotal += (get_time() - tc);
|
||||
}
|
||||
double tRadRes = tRadTotal / AVG_TIME_LOOPS;
|
||||
double tHeapRes = tHeapTotal / AVG_TIME_LOOPS;
|
||||
double tBubblRes = tBubblTotal / AVG_TIME_LOOPS;
|
||||
|
||||
free(arrA);
|
||||
free(arrB);
|
||||
free(arrC);
|
||||
|
||||
fprintf(f, "%d %f %f %f\n", n, tRadRes, tHeapRes, tBubblRes);
|
||||
free(arr);
|
||||
printf("Sort: %d/%d \r", n, end);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
@@ -20,9 +20,5 @@ $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
@mkdir -p $(OBJ_DIR)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
run: $(TARGET)
|
||||
./$(TARGET) < input > output
|
||||
@cat output
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJ_DIR) $(TARGET) output
|
||||
|
||||
Binary file not shown.
Submodule 1Y-2H/gameoflife deleted from feb40df734
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,28 +0,0 @@
|
||||
CC = gcc
|
||||
|
||||
CFLAGS = -Wall -Wextra -I../ -g
|
||||
TARGET = matrix
|
||||
|
||||
SRC_DIR = ../code
|
||||
OBJ_DIR = ../.o
|
||||
|
||||
SRCS = $(wildcard $(SRC_DIR)/*.c)
|
||||
OBJS = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRCS))
|
||||
|
||||
.PHONY: all clean run
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CC) $(CFLAGS) $(OBJS) -o $(TARGET)
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
||||
@mkdir -p $(OBJ_DIR)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
run: $(TARGET)
|
||||
./$(TARGET) < input > output
|
||||
@cat output
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJ_DIR) $(TARGET) output
|
||||
@@ -0,0 +1,44 @@
|
||||
[
|
||||
{
|
||||
"file": "src/io.c",
|
||||
"arguments": [
|
||||
"gcc",
|
||||
"-I./include",
|
||||
"-g",
|
||||
"-c",
|
||||
"src/io.c",
|
||||
"-o",
|
||||
".obj/io.o"
|
||||
],
|
||||
"directory": "/home/oniic/Documents/sibsutisiv522s18/1Y-2H/prog",
|
||||
"output": ".obj/io.o"
|
||||
},
|
||||
{
|
||||
"file": "src/main.c",
|
||||
"arguments": [
|
||||
"gcc",
|
||||
"-I./include",
|
||||
"-g",
|
||||
"-c",
|
||||
"src/main.c",
|
||||
"-o",
|
||||
".obj/main.o"
|
||||
],
|
||||
"directory": "/home/oniic/Documents/sibsutisiv522s18/1Y-2H/prog",
|
||||
"output": ".obj/main.o"
|
||||
},
|
||||
{
|
||||
"file": "src/matrix.c",
|
||||
"arguments": [
|
||||
"gcc",
|
||||
"-I./include",
|
||||
"-g",
|
||||
"-c",
|
||||
"src/matrix.c",
|
||||
"-o",
|
||||
".obj/matrix.o"
|
||||
],
|
||||
"directory": "/home/oniic/Documents/sibsutisiv522s18/1Y-2H/prog",
|
||||
"output": ".obj/matrix.o"
|
||||
}
|
||||
]
|
||||
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user