Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vs/*
3 changes: 3 additions & 0 deletions .vs/CMakeWorkspaceSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"enableCMake": false
}
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": "\u041D\u0435\u0442 \u043A\u043E\u043D\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439"
}
8 changes: 8 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"ExpandedNodes": [
"",
"\\05_hw"
],
"SelectedNode": "\\.gitignore",
"PreviewInSolutionExplorer": false
}
Binary file added .vs/cmake.db
Binary file not shown.
Binary file added .vs/lecture-testing-task/v17/.wsuo
Binary file not shown.
Binary file added .vs/lecture-testing-task/v17/Browse.VC.db
Binary file not shown.
102 changes: 102 additions & 0 deletions .vs/lecture-testing-task/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"Version": 1,
"WorkspaceRootPath": "E:\\1\\lecture-testing-task\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|E:\\1\\lecture-testing-task\\.gitignore||{3B902123-F8A7-4915-9F01-361F908088D0}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:.gitignore||{3B902123-F8A7-4915-9F01-361F908088D0}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|E:\\1\\lecture-testing-task\\05_hw\\benchmark_stack.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:05_hw\\benchmark_stack.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|E:\\1\\lecture-testing-task\\05_hw\\CMakeLists.txt||{8B382828-6202-11D1-8870-0000F87579D2}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:05_hw\\CMakeLists.txt||{8B382828-6202-11D1-8870-0000F87579D2}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|E:\\1\\lecture-testing-task\\05_hw\\stack.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:05_hw\\stack.h||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{
"AbsoluteMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|E:\\1\\lecture-testing-task\\05_hw\\test_stack.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{A2FE74E1-B743-11D0-AE1A-00A0C90FFFC3}|\u003CMiscFiles\u003E|solutionrelative:05_hw\\test_stack.c||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 0,
"Children": [
{
"$type": "Document",
"DocumentIndex": 0,
"Title": ".gitignore",
"DocumentMoniker": "E:\\1\\lecture-testing-task\\.gitignore",
"RelativeDocumentMoniker": ".gitignore",
"ToolTip": "E:\\1\\lecture-testing-task\\.gitignore",
"RelativeToolTip": ".gitignore",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAFAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001001|",
"WhenOpened": "2024-11-22T18:17:24.586Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 2,
"Title": "CMakeLists.txt",
"DocumentMoniker": "E:\\1\\lecture-testing-task\\05_hw\\CMakeLists.txt",
"RelativeDocumentMoniker": "05_hw\\CMakeLists.txt",
"ToolTip": "E:\\1\\lecture-testing-task\\05_hw\\CMakeLists.txt",
"RelativeToolTip": "05_hw\\CMakeLists.txt",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAwAAAAsAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.003109|",
"WhenOpened": "2024-11-22T17:47:42.417Z"
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "benchmark_stack.c",
"DocumentMoniker": "E:\\1\\lecture-testing-task\\05_hw\\benchmark_stack.c",
"RelativeDocumentMoniker": "05_hw\\benchmark_stack.c",
"ToolTip": "E:\\1\\lecture-testing-task\\05_hw\\benchmark_stack.c",
"RelativeToolTip": "05_hw\\benchmark_stack.c",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAA4AAAABAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000423|",
"WhenOpened": "2024-11-22T17:44:26.91Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 4,
"Title": "test_stack.c",
"DocumentMoniker": "E:\\1\\lecture-testing-task\\05_hw\\test_stack.c",
"RelativeDocumentMoniker": "05_hw\\test_stack.c",
"ToolTip": "E:\\1\\lecture-testing-task\\05_hw\\test_stack.c",
"RelativeToolTip": "05_hw\\test_stack.c",
"ViewState": "AgIAADYAAAAAAAAAAAAAAFMAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000423|",
"WhenOpened": "2024-11-22T16:02:47.904Z"
},
{
"$type": "Document",
"DocumentIndex": 3,
"Title": "stack.h",
"DocumentMoniker": "E:\\1\\lecture-testing-task\\05_hw\\stack.h",
"RelativeDocumentMoniker": "05_hw\\stack.h",
"ToolTip": "E:\\1\\lecture-testing-task\\05_hw\\stack.h",
"RelativeToolTip": "05_hw\\stack.h",
"ViewState": "AgIAAAAAAAAAAAAAAAAAACQAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
"WhenOpened": "2024-11-22T16:00:49.8Z"
}
]
}
]
}
]
}
Binary file added .vs/lecture-testing-task/v17/Solution.VC.db
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 added .vs/slnx.sqlite
Binary file not shown.
9 changes: 9 additions & 0 deletions 05_hw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@ add_library(stack stack.c)

add_executable(main main.c)
target_link_libraries(main stack)

add_executable(test_stack test_stack.c)
target_link_libraries(test_stack stack)

add_executable(benchmark_stack benchmark_stack.c)
target_link_libraries(benchmark_stack stack)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
40 changes: 40 additions & 0 deletions 05_hw/benchmark_stack.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "stack.h"

#define NUM_ELEMENTS 1000000 // ���������� ��������� ��� �����

void benchmark_push(Stack* stack) {
clock_t start = clock();
for (int i = 0; i < NUM_ELEMENTS; i++) {
push(stack, i);
}
clock_t end = clock();
printf("Time for push (%d elements): %f seconds\n", NUM_ELEMENTS, (double)(end - start) / CLOCKS_PER_SEC);
}

void benchmark_pop(Stack* stack) {
clock_t start = clock();
for (int i = 0; i < NUM_ELEMENTS; i++) {
pop(stack);
}
clock_t end = clock();
printf("Time for pop (%d elements): %f seconds\n", NUM_ELEMENTS, (double)(end - start) / CLOCKS_PER_SEC);
}

int main() {
Stack stack;
initStack(&stack);

printf("Running benchmarks...\n");

// �������� ��� push
benchmark_push(&stack);

// �������� ��� pop
benchmark_pop(&stack);

destroyStack(&stack);
return 0;
}
Loading