logging

parent e5f39f14
#!/bin/bash
# Process information in the log file to get the duration of subroutines.
# This script depends highly on the data structure of the log file (which may
# change)
#!/bin/bash
input="/path/to/txt/file"
while IFS= read -r line1
do
if [ "$(echo $line1 | cut -d' ' -f2)" == "step" ]
then
echo
echo $line1 | cut -d' ' -f2,3
continue
fi
IFS= read -r line2
progname=$(echo "$line1" | cut -d' ' -f2)
start_time=$(echo "$line1" | cut -d' ' -f1)
stop_time=$(echo "$line2" | cut -d' ' -f1)
progtime=$(date -u -d "0 $stop_time sec - $start_time sec" +"%T")
printf -v pad %10s
padded_progname="$progname$pad"
padded_progname="${padded_progname:0:10}"
echo "$padded_progname $progtime"
done < "$1"
......@@ -22,6 +22,7 @@ static bool STOP_CRITERION = false;
#include "./polynomial.h"
#include "./utils.h"
#include "./macros.h"
#include "./logger.h"
namespace tinygb {
......@@ -57,6 +58,7 @@ std::vector<Polynomial> F4() {
(!STOP_CRITERION || !stop_crit)) {
std::cerr << "step " << step_number << std::endl;
Logger("/tmp/log_tinygb").log("step " + std::to_string(step_number));
TINYGB_TRY(SaveCritPairs("critpairs_glob.txt", global_critical_pairs), "f4");
std::system(("build/selcrit/selcrit " + WORKDIR + " critpairs_glob.txt critpairs_step.txt").c_str());
......
#include "logger.h"
namespace tinygb {
void Logger::log(const std::string& s) {
std::system(("echo $(date +\"%s\") " + s + " >> " + filename_).c_str());
std::system(("echo $(date +\"%s\") \"" + s + "\" >> " + filename_).c_str());
}
} // namespace tinygb
......@@ -3,6 +3,8 @@
#include <string>
namespace tinygb {
class Logger {
public:
Logger(const std::string filename)
......@@ -14,4 +16,6 @@ class Logger {
std::string filename_;
};
} // namespace tinygb
#endif
......@@ -2,6 +2,7 @@ Import('env')
source_files = ['matmulsub.cc',
'#src/monomial.cc',
'#src/logger.cc',
'#src/polynomial.cc',
'#src/critical_pair.cc',
'#src/polynomial_in_matrix.cc',
......
......@@ -5,6 +5,7 @@
#include "./givaro_wrapper.h"
#include "./common.h"
#include "./macros.h"
#include "./logger.h"
namespace tinygb {
......@@ -39,10 +40,9 @@ matmulsub(
} // namespace tinygb
int
main(int argc, char **argv) {
int main(int argc, char **argv) {
std::cerr << "matmulsub: start" << std::endl;
tinygb::Logger("/tmp/log_tinygb").log("matmulsub start");
(void)argc; // To get rid of the warning -Wunused-parameter argc
......@@ -52,6 +52,7 @@ main(int argc, char **argv) {
tinygb::matmulsub(argv[2], argv[3], argv[4], argv[5]);
std::cerr << "matmulsub: end" << std::endl;
tinygb::Logger("/tmp/log_tinygb").log("matmulsub stop");
return EXIT_SUCCESS;
}
......@@ -2,6 +2,7 @@ Import('env')
source_files = ['rowech.cc',
'#src/givaro_wrapper.cc',
'#src/logger.cc',
'#src/monomial.cc',
'#src/critical_pair.cc',
'#src/polynomial_in_matrix.cc',
......
......@@ -4,6 +4,7 @@
#include "./givaro_wrapper.h"
#include "./matrices/rowmajmat.h"
#include "./macros.h"
#include "./logger.h"
#include <iostream>
namespace tinygb {
......@@ -61,6 +62,7 @@ rowech(std::string resD_file, std::string resB_file,
int
main(int argc, char **argv) {
std::cerr << "rowech: start" << std::endl;
tinygb::Logger("/tmp/log_tinygb").log("rowech start");
(void)argc; // To get rid of the warning -Wunused-parameter argc
......@@ -70,6 +72,7 @@ main(int argc, char **argv) {
tinygb::rowech(argv[2], argv[3], argv[4], argv[5]);
std::cerr << "rowech: end" << std::endl;
tinygb::Logger("/tmp/log_tinygb").log("rowech stop");
return EXIT_SUCCESS;
}
......@@ -10,6 +10,7 @@ source_files = ['utsolve.cc',
'#src/matrices/io_utils.cc',
'#src/utils.cc',
'#src/glob_params.cc',
'#src/givaro_wrapper.cc']
'#src/givaro_wrapper.cc',
'#src/logger.cc']
env.Program('utsolve', source_files)
......@@ -7,11 +7,11 @@
#include "./matrices/rowmajmat.h"
#include "./givaro_wrapper.h"
#include "./macros.h"
#include "./logger.h"
namespace tinygb {
void utsolve(std::string res_file, std::string matA_file, std::string matB_file)
{
void utsolve(std::string res_file, std::string matA_file, std::string matB_file) {
std::shared_ptr<SpMat> pA = nullptr;
std::shared_ptr<RowMajMat> pB = nullptr;
......@@ -24,9 +24,9 @@ void utsolve(std::string res_file, std::string matA_file, std::string matB_file)
}
int main(int argc, char **argv)
{
int main(int argc, char **argv) {
std::cerr << "utsolve: start" << std::endl;
tinygb::Logger("/tmp/log_tinygb").log("utsolve start");
(void)argc; // To get rid of the warning -Wunused-parameter argc
......@@ -36,6 +36,7 @@ int main(int argc, char **argv)
tinygb::utsolve(argv[2], argv[3], argv[4]);
std::cerr << "utsolve: end" << std::endl;
tinygb::Logger("/tmp/log_tinygb").log("utsolve stop");
return EXIT_SUCCESS;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment