From 108671175c902958d08fc2d8656613d06a40fc8e Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Fri, 14 Mar 2008 06:10:54 +0000 Subject: [PATCH] Greatly improved I/O speed on gorgonsub Originally committed to SVN as r2053. --- aegilib/src/controller.cpp | 10 ++++++---- aegilib/test/src/main.cpp | 14 +++++++++++--- aegilib/test/test.vcproj | 1 + 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/aegilib/src/controller.cpp b/aegilib/src/controller.cpp index 9ee9a747d..ebdd0a22e 100644 --- a/aegilib/src/controller.cpp +++ b/aegilib/src/controller.cpp @@ -59,8 +59,9 @@ ActionListPtr Controller::CreateActionList(const String title,const String owner void Controller::LoadFile(const String filename,const String encoding) { const FormatPtr handler = FormatManager::GetFormatFromFilename(filename,true); - wxFileInputStream stream(filename); - model.Load(stream,handler,encoding); + wxFFileInputStream stream(filename); + wxBufferedInputStream buffer(stream); + model.Load(buffer,handler,encoding); } @@ -69,8 +70,9 @@ void Controller::LoadFile(const String filename,const String encoding) void Controller::SaveFile(const String filename,const String encoding) { const FormatPtr handler = FormatManager::GetFormatFromFilename(filename,true); - wxFileOutputStream stream(filename); - model.Save(stream,handler,encoding); + wxFFileOutputStream stream(filename); + wxBufferedOutputStream buffer(stream); + model.Save(buffer,handler,encoding); } diff --git a/aegilib/test/src/main.cpp b/aegilib/test/src/main.cpp index d25742e6f..5d3ee7e72 100644 --- a/aegilib/test/src/main.cpp +++ b/aegilib/test/src/main.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include "text_file_reader.h" #include "text_file_writer.h" @@ -53,11 +54,14 @@ int main () { // Subtitles model Model subs; Controller control(subs); + wxStopWatch timer; // Load subtitles cout << "Loading file... "; + timer.Start(); control.LoadFile(L"subs_in.ass",L"UTF-8"); - cout << "Done.\n"; + timer.Pause(); + cout << "Done in " << timer.Time() << "ms.\n"; // Create line to be inserted cout << "Creating data... "; @@ -67,11 +71,13 @@ int main () { // Create action list cout << "Processing actions... "; + timer.Start(); ActionListPtr actions = control.CreateActionList(L"Insert line"); actions->InsertLine(line,2); actions->RemoveLine(3,L"Events"); actions->Finish(); - cout << "Done.\n"; + timer.Pause(); + cout << "Done in " << timer.Time() << "ms.\n"; // Save subtitles cout << "Saving file... "; @@ -95,8 +101,10 @@ int main () { // Save subtitles cout << "Saving file... "; + timer.Start(); control.SaveFile(L"subs_out.ass",L"UTF-8"); - cout << "Done.\n"; + timer.Pause(); + cout << "Done in " << timer.Time() << "ms.\n"; } catch (std::exception &e) { diff --git a/aegilib/test/test.vcproj b/aegilib/test/test.vcproj index c6b533809..b276e8b4b 100644 --- a/aegilib/test/test.vcproj +++ b/aegilib/test/test.vcproj @@ -143,6 +143,7 @@ OptimizeReferences="2" EnableCOMDATFolding="2" TargetMachine="1" + Profile="true" />