jacobian

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 6c3ed655db0e33e75b149fb52b7b28479f233963
parent 397f25ebd75cf10c3a57ef0599dab8092100bf6d
Author: David Freifeld <freifeld.david@gmail.com>
Date:   Tue, 22 Sep 2020 13:24:52 -0700

backing up

Diffstat:
Msrc/experimental/fileread.cpp | 26+++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/experimental/fileread.cpp b/src/experimental/fileread.cpp @@ -100,12 +100,12 @@ void prep() float newer() { - static const auto BUFFER_SIZE = 100*1024; + static const auto BUFFER_SIZE = 2000*1024; int fd = open("../../data_banknote_authentication.bin", O_RDONLY | O_NONBLOCK); uintmax_t maxlines = 1003222; if(fd == -1) { - printf("fd == -1\n"); - return 1; + printf("Cannot open file."); + exit(1); } char buf[BUFFER_SIZE]; uintmax_t lines = 0; @@ -114,38 +114,42 @@ float newer() { if(bytes_read == (size_t)-1) { printf("bytes_read == (size_t)-1\n"); - return 1; + exit(1); } if (!bytes_read) break; for(char *p = buf; p < buf+BUFFER_SIZE;) { //if (lines > maxlines) break; for (int i=0; i<5; ++i) { tmp = *((float*)p); - if (lines % 1342 == 0 || lines >= maxlines) printf("%f ", tmp); + //if (lines % 1342 == 0 || lines >= maxlines) printf("%f ", tmp); p += sizeof(float); } - if (lines % 1342 == 0 || lines >= maxlines) printf("\n"); + //if (lines % 1342 == 0 || lines >= maxlines) printf("\n"); // printf("\n"); //if (lines > BUFFER_SIZE / 20 + 1) assert(0); ++lines; } - // printf("lines %d (%f)\n", lines, tmp); } - printf("%ju\n", lines); return tmp; } int main () { + int epochs = 10; + float tmp; auto start = std::chrono::high_resolution_clock::now(); prep(); auto prep_end = std::chrono::high_resolution_clock::now(); - float tmp = newer(); + for (int i = 0; i < epochs; i++) { + tmp = newer(); + } auto end = std::chrono::high_resolution_clock::now(); double time = std::chrono::duration_cast<std::chrono::nanoseconds>(end - prep_end + prep_end-start).count() / pow(10,9); double runtime = std::chrono::duration_cast<std::chrono::nanoseconds>(end - prep_end).count() / pow(10,9); - + float ftmp; auto f_start = std::chrono::high_resolution_clock::now(); - float ftmp = current(); + for (int i = 0; i < epochs; i++) { + ftmp = current(); + } auto f_end = std::chrono::high_resolution_clock::now(); // if (flines == lines) std::cout << "Linecount is valid!" << "\n"; // else std::cout << "WARN: INVALID LINECOUNT " << lines << " vs. " << flines << "\n";