mirror of
https://github.com/jorenchik/mdemory.git
synced 2026-03-22 00:26:21 +00:00
paramerized show time and debug in global config
Also some additional time measurements in the qt app.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <format>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
@@ -64,6 +63,7 @@
|
||||
#include <QShortcut>
|
||||
#include <QWidget>
|
||||
|
||||
#include "config.h"
|
||||
#include "settings.h"
|
||||
#include "mdemList.h"
|
||||
#include "trainWindow.h"
|
||||
@@ -573,6 +573,7 @@ void reloadMdem(std::string path) {
|
||||
return;
|
||||
}
|
||||
|
||||
start = std::chrono::high_resolution_clock::now();
|
||||
auto file = std::ifstream(path);
|
||||
std::string content;
|
||||
|
||||
@@ -589,7 +590,13 @@ void reloadMdem(std::string path) {
|
||||
std::stringstream buffer;
|
||||
buffer << file.rdbuf();
|
||||
content = buffer.str();
|
||||
auto res = transpile(content, true);
|
||||
end = std::chrono::high_resolution_clock::now();
|
||||
showTimes = settings->value(SETTING_SHOW_TIMES).toBool();
|
||||
if (showTimes) {
|
||||
std::cout << showTime("I/O time") << std::endl;
|
||||
}
|
||||
debug = settings->value(SETTING_DEBUG).toBool();
|
||||
auto res = transpile(content);
|
||||
|
||||
currentMdemBuffer->error = res.error.length() > 0;
|
||||
if (res.error == "") {
|
||||
@@ -599,7 +606,11 @@ void reloadMdem(std::string path) {
|
||||
auto timezoneOffset = settings->value("timezone").toInt();
|
||||
currentMdemBuffer->trainedAt = res.value.lastTrainedAt - 3600 * timezoneOffset;
|
||||
}
|
||||
std::cout << std::format("Last trained at: {}", currentMdemBuffer->trainedAt) << std::endl;
|
||||
|
||||
if (settings->value(SETTING_DEBUG).toBool()) {
|
||||
std::cout << std::format("Last trained at: {}", currentMdemBuffer->trainedAt)
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
currentMdemBuffer->questions = res.value.questions;
|
||||
errorView->box.hide();
|
||||
@@ -676,7 +687,9 @@ void pickDirectory(QString directory) {
|
||||
}
|
||||
|
||||
void setupEditorSave() {
|
||||
auto res = transpile(editor->text().toStdString(), true);
|
||||
debug = settings->value(SETTING_DEBUG).toBool();
|
||||
showTimes = settings->value(SETTING_SHOW_TIMES).toBool();
|
||||
auto res = transpile(editor->text().toStdString());
|
||||
if (res.error.length() > 0) {
|
||||
currentMdemBuffer->trainedAt = 0;
|
||||
for (auto question: res.value.questions) {
|
||||
@@ -740,12 +753,19 @@ void setupEditorSave() {
|
||||
};
|
||||
|
||||
void saveMdem() {
|
||||
start = std::chrono::high_resolution_clock::now();
|
||||
|
||||
auto filename = getFilename(currentMdem);
|
||||
std::ofstream out(currentMdem);
|
||||
out << outputMdem(currentMdemBuffer->questions, currentMdemBuffer->trainedAt);
|
||||
updateMdemInfo(getFilename(currentMdem), false);
|
||||
}
|
||||
end = std::chrono::high_resolution_clock::now();
|
||||
|
||||
showTimes = settings->value(SETTING_SHOW_TIMES).toBool();
|
||||
if (showTimes) {
|
||||
std::cout << showTime("Saving time") << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
QMainWindow *initMdemListWindow() {
|
||||
QMainWindow* window = new QMainWindow;
|
||||
|
||||
Reference in New Issue
Block a user