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
Binary file added homework/Erofeev/01/sum_by_columns
Binary file not shown.
43 changes: 43 additions & 0 deletions homework/Erofeev/01/sum_by_columns.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include <chrono>
#include <iostream>

using ll = long long;

const int SIZE = 10000;
int matrix[SIZE][SIZE];
volatile ll sum = 0;

class Timer
{
using clock_t = std::chrono::high_resolution_clock;
using microseconds = std::chrono::microseconds;
public:
Timer()
: start_(clock_t::now())
{
}

~Timer()
{
const auto finish = clock_t::now();
const auto us =
std::chrono::duration_cast<microseconds>
(finish - start_).count();
std::cout << us << std::endl;
}

private:
const clock_t::time_point start_;
};

int main() {
for (int i = 0; i < SIZE; i++)
for (int j = 0; j < SIZE; j++)
matrix[j][i] = i + j;

Timer t;
sum = 0;
for (int i = 0; i < SIZE; i++)
for (int j = 0; j < SIZE; j++)
sum += matrix[j][i];
}
48 changes: 48 additions & 0 deletions homework/Erofeev/01/sum_by_columns.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
196223
192879
193763
192840
193193
193996
192312
192547
194233
192549
196355
192513
195145
196452
203844
228275
221790
193186
195710
202728
194287
193145
208523
200879
196704
193552
193250
192877
192855
194121
193148
220713
222262
221502
218877
218021
213741
212756
232033
255283
243968
215759
196060
196219
196086
195670
194311
197658
Binary file added homework/Erofeev/01/sum_by_rows
Binary file not shown.
44 changes: 44 additions & 0 deletions homework/Erofeev/01/sum_by_rows.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <chrono>
#include <iostream>

using ll = long long;

const int SIZE = 10000;
int matrix[SIZE][SIZE];
ll sum = 0;


class Timer
{
using clock_t = std::chrono::high_resolution_clock;
using microseconds = std::chrono::microseconds;
public:
Timer()
: start_(clock_t::now())
{
}

~Timer()
{
const auto finish = clock_t::now();
const auto us =
std::chrono::duration_cast<microseconds>
(finish - start_).count();
std::cout << us << std::endl;
}

private:
const clock_t::time_point start_;
};

int main() {
for (int i = 0; i < SIZE; i++)
for (int j = 0; j < SIZE; j++)
matrix[i][j] = i + j;

Timer t;
sum = 0;
for (int i = 0; i < SIZE; i++)
for (int j = 0; j < SIZE; j++)
sum += matrix[i][j];
}
101 changes: 101 additions & 0 deletions homework/Erofeev/01/sum_by_rows.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
52985
49897
49788
49281
50158
49138
49092
48842
49298
48896
49093
48808
49135
49007
52563
49255
49241
49059
49141
48858
49323
48878
49120
49469
49416
49613
49332
52164
49012
49142
49145
49098
48998
49434
49699
49246
49335
50563
49192
49460
49317
49772
49093
50019
49464
49489
49314
49010
48929
49509
49287
49196
49163
49396
49322
49646
49055
49739
49160
51552
49855
49084
48950
49082
49446
49396
49160
49225
49087
49263
49392
49259
48865
50183
50535
50598
50325
49145
49091
49217
48914
49020
49372
48976
49126
51768
49386
52721
51019
49307
48981
48941
49030
49026
49167
49971
49260
49306
52644
49408
49520