benchmark_utils.h (1029B)
1 // Copyright (c) the JPEG XL Project Authors. All rights reserved. 2 // 3 // Use of this source code is governed by a BSD-style 4 // license that can be found in the LICENSE file. 5 6 #ifndef TOOLS_BENCHMARK_BENCHMARK_UTILS_H_ 7 #define TOOLS_BENCHMARK_BENCHMARK_UTILS_H_ 8 9 #include <string> 10 #include <vector> 11 12 #include "lib/jxl/base/status.h" 13 14 namespace jpegxl { 15 namespace tools { 16 17 using ::jxl::Status; 18 19 class TemporaryFile final { 20 public: 21 explicit TemporaryFile(std::string basename, std::string extension); 22 TemporaryFile(const TemporaryFile&) = delete; 23 TemporaryFile& operator=(const TemporaryFile&) = delete; 24 ~TemporaryFile(); 25 Status GetFileName(std::string* output) const; 26 27 private: 28 bool ok_ = true; 29 30 std::string temp_filename_; 31 }; 32 33 std::string GetBaseName(std::string filename); 34 35 Status RunCommand(const std::string& command, 36 const std::vector<std::string>& arguments, 37 bool quiet = false); 38 39 } // namespace tools 40 } // namespace jpegxl 41 42 #endif // TOOLS_BENCHMARK_BENCHMARK_UTILS_H_