Browse Source

Add timer

master
Jørgen Lien Sellæg 11 years ago
parent
commit
4069590048
  1. 2
      juci/CMakeLists.txt
  2. 9
      juci/source.cc
  3. 18
      juci/source.h

2
juci/CMakeLists.txt

@ -52,7 +52,7 @@ endif()
#Boost_INCLUDE_DIRS - Boost include directories #Boost_INCLUDE_DIRS - Boost include directories
#Boost_LIBRARY_DIRS - Link directories for Boost libraries #Boost_LIBRARY_DIRS - Link directories for Boost libraries
#Boost_LIBRARIES - Boost component libraries to be linked #Boost_LIBRARIES - Boost component libraries to be linked
find_package(Boost 1.5 REQUIRED COMPONENTS python) find_package(Boost 1.5 REQUIRED COMPONENTS python timer system)
#If boost is not found #If boost is not found
if(${Boost_FOUND}) if(${Boost_FOUND})

9
juci/source.cc

@ -3,6 +3,7 @@
#include "sourcefile.h" #include "sourcefile.h"
#include <boost/property_tree/json_parser.hpp> #include <boost/property_tree/json_parser.hpp>
#include <fstream> #include <fstream>
#include <boost/timer/timer.hpp>
////////////// //////////////
//// View //// //// View ////
@ -185,9 +186,12 @@ void Source::Controller::OnOpenFile(const string &filepath) {
int start_offset = buffer()->begin().get_offset(); int start_offset = buffer()->begin().get_offset();
int end_offset = buffer()->end().get_offset(); int end_offset = buffer()->end().get_offset();
std::string project_path = std::string project_path =
filepath.substr(0, filepath.find_last_of('/')); filepath.substr(0, filepath.find_last_of('/'));
clang::CompilationDatabase db(project_path); clang::CompilationDatabase db(project_path);
clang::CompileCommands commands(filepath, &db); clang::CompileCommands commands(filepath, &db);
std::vector<clang::CompileCommand> cmds = commands.get_commands(); std::vector<clang::CompileCommand> cmds = commands.get_commands();
@ -198,7 +202,10 @@ void Source::Controller::OnOpenFile(const string &filepath) {
arguments.emplace_back(lol[a].c_str()); arguments.emplace_back(lol[a].c_str());
} }
} }
boost::timer::auto_cpu_timer timer;
clang::TranslationUnit tu(true, filepath, arguments); clang::TranslationUnit tu(true, filepath, arguments);
timer.~auto_cpu_timer();
boost::timer::auto_cpu_timer timer2;
clang::SourceLocation start(&tu, filepath, start_offset); clang::SourceLocation start(&tu, filepath, start_offset);
clang::SourceLocation end(&tu, filepath, end_offset); clang::SourceLocation end(&tu, filepath, end_offset);
clang::SourceRange range(&start, &end); clang::SourceRange range(&start, &end);
@ -212,6 +219,8 @@ void Source::Controller::OnOpenFile(const string &filepath) {
loc.get_location_info(NULL, &line, &column, NULL); loc.get_location_info(NULL, &line, &column, NULL);
} }
timer2.~auto_cpu_timer();
// std::cout << t.elapsed().user << std::endl;
// model().SetSourceLocations(tu.getSourceLocations()); // model().SetSourceLocations(tu.getSourceLocations());
// view().OnOpenFile(model().getSourceLocations(), model().theme()); // view().OnOpenFile(model().getSourceLocations(), model().theme());
} }

18
juci/source.h

@ -24,6 +24,24 @@ namespace Source {
std::unordered_map<string, string> typetable_; std::unordered_map<string, string> typetable_;
string background_; string background_;
}; // class Theme }; // class Theme
/*
class BufferLocation {
BufferLocation(const BufferLocation &location);
BufferLocation(int, int);
int line_number() { return line_number_; }
int column_number() { return column_offset_; }
private:
int line_number_;
int column_offset_;
};
class BufferRange {
BufferRange(const BufferLocation &start, const BufferLocation &end) :
start_(start), end_(end) { }
private:
BufferLocation start_;
BufferLocation end_;
};*/
class View : public Gtk::TextView { class View : public Gtk::TextView {
public: public:

Loading…
Cancel
Save