diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2021-09-10 23:59:41 +0300 |
---|---|---|
committer | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2021-09-11 09:03:10 +0300 |
commit | 915eed04024f096f9644bf637387ab0455277202 (patch) | |
tree | e0b7b298ebf6d903cc80bb4cc944bfd1fb9b9d3c | |
parent | a0a235784fe38dbccff3bfcdb5a4930f51e2b2d6 (diff) |
SL-15964 Simple test for compression library
-rw-r--r-- | indra/newview/llviewermenu.cpp | 17 | ||||
-rw-r--r-- | indra/newview/llviewermenufile.cpp | 88 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/menu_viewer.xml | 6 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/notifications.xml | 10 |
4 files changed, 121 insertions, 0 deletions
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index ad81cb07c1..ba90becb60 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -202,6 +202,7 @@ LLContextMenu* gDetachBodyPartPieMenus[9]; // File Menu void handle_compress_image(void*); +void handle_compress_file_test(void*); // Edit menu @@ -2171,6 +2172,21 @@ class LLAdvancedCompressImage : public view_listener_t }; + +//////////////////////// +// COMPRESS FILE TEST // +//////////////////////// + +class LLAdvancedCompressFileTest : public view_listener_t +{ + bool handleEvent(const LLSD& userdata) + { + handle_compress_file_test(NULL); + return true; + } +}; + + ///////////////////////// // SHOW DEBUG SETTINGS // ///////////////////////// @@ -9284,6 +9300,7 @@ void initialize_menus() view_listener_t::addMenu(new LLAdvancedToggleShowObjectUpdates(), "Advanced.ToggleShowObjectUpdates"); view_listener_t::addMenu(new LLAdvancedCheckShowObjectUpdates(), "Advanced.CheckShowObjectUpdates"); view_listener_t::addMenu(new LLAdvancedCompressImage(), "Advanced.CompressImage"); + view_listener_t::addMenu(new LLAdvancedCompressFileTest(), "Advanced.CompressFileTest"); view_listener_t::addMenu(new LLAdvancedShowDebugSettings(), "Advanced.ShowDebugSettings"); view_listener_t::addMenu(new LLAdvancedEnableViewAdminOptions(), "Advanced.EnableViewAdminOptions"); view_listener_t::addMenu(new LLAdvancedToggleViewAdminOptions(), "Advanced.ToggleViewAdminOptions"); diff --git a/indra/newview/llviewermenufile.cpp b/indra/newview/llviewermenufile.cpp index 15181dcd9f..43f99fc13a 100644 --- a/indra/newview/llviewermenufile.cpp +++ b/indra/newview/llviewermenufile.cpp @@ -775,6 +775,94 @@ void handle_compress_image(void*) } } +// No convinient check in LLFile, and correct way would be something +// like GetFileSizeEx, which is too OS specific for current purpose +// so doing dirty, but OS independent fopen and fseek +size_t get_file_size(std::string &filename) +{ + LLFILE* file = LLFile::fopen(filename, "rb"); /*Flawfinder: ignore*/ + if (!file) + { + LL_WARNS() << "Error opening " << filename << LL_ENDL; + return 0; + } + + // read in the whole file + fseek(file, 0L, SEEK_END); + size_t file_length = (size_t)ftell(file); + fclose(file); + return file_length; +} + +void handle_compress_file_test(void*) +{ + LLFilePicker& picker = LLFilePicker::instance(); + if (picker.getOpenFile()) + { + std::string infile = picker.getFirstFile(); + if (!infile.empty()) + { + std::string packfile = infile + ".pack_test"; + std::string unpackfile = infile + ".unpack_test"; + + S64Bytes initial_size = S64Bytes(get_file_size(infile)); + + BOOL success; + + F64 total_seconds = LLTimer::getTotalSeconds(); + success = gzip_file(infile, packfile); + F64 result_pack_seconds = LLTimer::getTotalSeconds() - total_seconds; + + if (success) + { + S64Bytes packed_size = S64Bytes(get_file_size(packfile)); + + LL_INFOS() << "Packing complete, time: " << result_pack_seconds << " size: " << packed_size << LL_ENDL; + total_seconds = LLTimer::getTotalSeconds(); + success = gunzip_file(packfile, unpackfile); + F64 result_unpack_seconds = LLTimer::getTotalSeconds() - total_seconds; + + if (success) + { + S64Bytes unpacked_size = S64Bytes(get_file_size(unpackfile)); + + LL_INFOS() << "Unpacking complete, time: " << result_unpack_seconds << " size: " << unpacked_size << LL_ENDL; + + LLSD args; + args["FILE"] = infile; + args["PACK_TIME"] = result_pack_seconds; + args["UNPACK_TIME"] = result_unpack_seconds; + args["SIZE"] = LLSD::Integer(initial_size.valueInUnits<LLUnits::Kilobytes>()); + args["PSIZE"] = LLSD::Integer(packed_size.valueInUnits<LLUnits::Kilobytes>()); + args["USIZE"] = LLSD::Integer(unpacked_size.valueInUnits<LLUnits::Kilobytes>()); + LLNotificationsUtil::add("CompressionTestResults", args); + + LLFile::remove(packfile); + LLFile::remove(unpackfile); + } + else + { + LL_INFOS() << "Failed to uncompress file: " << packfile << LL_ENDL; + LLFile::remove(packfile); + } + + } + else + { + LL_INFOS() << "Failed to compres file: " << infile << LL_ENDL; + } + } + else + { + LL_INFOS() << "Failed to open file" << LL_ENDL; + } + } + else + { + LL_INFOS() << "Failed to open file" << LL_ENDL; + } +} + LLUUID upload_new_resource( const std::string& src_filename, diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index 72cce2208f..6ddaa99f78 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -3883,6 +3883,12 @@ function="World.EnvPreset" <menu_item_call.on_click function="Advanced.CompressImage" /> </menu_item_call> + <menu_item_call + label="Compress File Test" + name="Compress File Test"> + <menu_item_call.on_click + function="Advanced.CompressFileTest" /> + </menu_item_call> <menu_item_call label="Enable Visual Leak Detector" diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 70fe84736f..b769d20106 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -11788,5 +11788,15 @@ Unable to load the track into [TRACK]. Unable to load the track from [TRACK1] into [TRACK2]. <tag>fail</tag> </notification> + + <notification + icon="alertmodal.tga" + name="CompressionTestResults" + type="alertmodal"> +Test result for gzip level 6 file compression with [FILE] of size [SIZE] KB: +Packing: [PACK_TIME]s [PSIZE]KB +Unpacking: [UNPACK_TIME]s [USIZE]KB + <tag>fail</tag> + </notification> </notifications> |