@@ -76,6 +76,10 @@ BENCHMARK_CAPTURE(BM_Initialization, s2tw, "s2tw")
7676 ->Unit (benchmark::kMillisecond );
7777BENCHMARK_CAPTURE (BM_Initialization, s2twp, " s2twp" )
7878 ->Unit (benchmark::kMillisecond );
79+ #ifdef ENABLE_JIEBA
80+ BENCHMARK_CAPTURE (BM_Initialization, s2twp_jieba, " s2twp_jieba" )
81+ ->Unit(benchmark::kMillisecond );
82+ #endif
7983BENCHMARK_CAPTURE (BM_Initialization, t2hk, " t2hk" )
8084 ->Unit (benchmark::kMillisecond );
8185BENCHMARK_CAPTURE (BM_Initialization, t2jp, " t2jp" )
@@ -85,6 +89,10 @@ BENCHMARK_CAPTURE(BM_Initialization, tw2s, "tw2s")
8589 ->Unit (benchmark::kMillisecond );
8690BENCHMARK_CAPTURE (BM_Initialization, tw2sp, " tw2sp" )
8791 ->Unit (benchmark::kMillisecond );
92+ #ifdef ENABLE_JIEBA
93+ BENCHMARK_CAPTURE (BM_Initialization, tw2sp_jieba, " tw2sp_jieba" )
94+ ->Unit(benchmark::kMillisecond );
95+ #endif
8896BENCHMARK_CAPTURE (BM_Initialization, tw2t, " tw2t" )
8997 ->Unit (benchmark::kMillisecond );
9098
@@ -97,6 +105,26 @@ static void BM_Convert2M(benchmark::State& state) {
97105 }
98106}
99107BENCHMARK (BM_Convert2M)->Unit (benchmark::kMillisecond );
108+ #ifdef ENABLE_JIEBA
109+ static void BM_Convert2M_Jieba (benchmark::State& state) {
110+ const std::string config_name = " s2twp_jieba" ;
111+ const std::string text = ReadText (" zuozhuan.txt" );
112+ const std::unique_ptr<SimpleConverter> converter (Initialize (config_name));
113+ for (auto _ : state) {
114+ Convert (converter.get (), text);
115+ }
116+ }
117+ BENCHMARK (BM_Convert2M_Jieba)->Unit(benchmark::kMillisecond );
118+ static void BM_Convert2M_Tw2spJieba (benchmark::State& state) {
119+ const std::string config_name = " tw2sp_jieba" ;
120+ const std::string text = ReadText (" zuozhuan.txt" );
121+ const std::unique_ptr<SimpleConverter> converter (Initialize (config_name));
122+ for (auto _ : state) {
123+ Convert (converter.get (), text);
124+ }
125+ }
126+ BENCHMARK (BM_Convert2M_Tw2spJieba)->Unit(benchmark::kMillisecond );
127+ #endif
100128
101129static void BM_Convert (benchmark::State& state, int iteration) {
102130 std::ostringstream os;
@@ -114,6 +142,45 @@ BENCHMARK_CAPTURE(BM_Convert, 100, 100)->Unit(benchmark::kMillisecond);
114142BENCHMARK_CAPTURE (BM_Convert, 1000 , 1000 )->Unit (benchmark::kMillisecond );
115143BENCHMARK_CAPTURE (BM_Convert, 10000 , 10000 )->Unit (benchmark::kMillisecond );
116144BENCHMARK_CAPTURE (BM_Convert, 100000 , 100000 )->Unit (benchmark::kMillisecond );
145+ #ifdef ENABLE_JIEBA
146+ static void BM_Convert_Jieba (benchmark::State& state, int iteration) {
147+ std::ostringstream os;
148+ for (int i = 0 ; i < iteration; i++) {
149+ os << " Open Chinese Convert 開放中文轉換" << i << std::endl;
150+ }
151+ const std::string text = os.str ();
152+ const std::string config_name = " s2twp_jieba" ;
153+ const std::unique_ptr<SimpleConverter> converter (Initialize (config_name));
154+ for (auto _ : state) {
155+ Convert (converter.get (), text);
156+ }
157+ }
158+ BENCHMARK_CAPTURE (BM_Convert_Jieba, 100 , 100 )->Unit(benchmark::kMillisecond );
159+ BENCHMARK_CAPTURE (BM_Convert_Jieba, 1000 , 1000 )->Unit(benchmark::kMillisecond );
160+ BENCHMARK_CAPTURE (BM_Convert_Jieba, 10000 , 10000 )->Unit(benchmark::kMillisecond );
161+ BENCHMARK_CAPTURE (BM_Convert_Jieba, 100000 , 100000 )
162+ ->Unit(benchmark::kMillisecond );
163+ static void BM_Convert_Tw2spJieba (benchmark::State& state, int iteration) {
164+ std::ostringstream os;
165+ for (int i = 0 ; i < iteration; i++) {
166+ os << " Open Chinese Convert 開放中文轉換" << i << std::endl;
167+ }
168+ const std::string text = os.str ();
169+ const std::string config_name = " tw2sp_jieba" ;
170+ const std::unique_ptr<SimpleConverter> converter (Initialize (config_name));
171+ for (auto _ : state) {
172+ Convert (converter.get (), text);
173+ }
174+ }
175+ BENCHMARK_CAPTURE (BM_Convert_Tw2spJieba, 100 , 100 )
176+ ->Unit(benchmark::kMillisecond );
177+ BENCHMARK_CAPTURE (BM_Convert_Tw2spJieba, 1000 , 1000 )
178+ ->Unit(benchmark::kMillisecond );
179+ BENCHMARK_CAPTURE (BM_Convert_Tw2spJieba, 10000 , 10000 )
180+ ->Unit(benchmark::kMillisecond );
181+ BENCHMARK_CAPTURE (BM_Convert_Tw2spJieba, 100000 , 100000 )
182+ ->Unit(benchmark::kMillisecond );
183+ #endif
117184
118185} // namespace opencc
119186
0 commit comments