File tree Expand file tree Collapse file tree 1 file changed +23
-10
lines changed Expand file tree Collapse file tree 1 file changed +23
-10
lines changed Original file line number Diff line number Diff line change @@ -1364,23 +1364,36 @@ func Benchmark_DiffCommonSuffix(b *testing.B) {
1364
1364
}
1365
1365
1366
1366
func Benchmark_DiffMainLarge (b * testing.B ) {
1367
- bytes1 , err := ioutil .ReadFile ("speedtest1.txt" )
1368
- if err != nil {
1369
- b .Fatal (err )
1370
- }
1371
- bytes2 , err := ioutil .ReadFile ("speedtest2.txt" )
1372
- if err != nil {
1373
- b .Fatal (err )
1374
- }
1375
- s1 := string (bytes1 )
1376
- s2 := string (bytes2 )
1367
+ s1 := readFile ("speedtest1.txt" , b )
1368
+ s2 := readFile ("speedtest2.txt" , b )
1377
1369
dmp := New ()
1378
1370
b .ResetTimer ()
1379
1371
for i := 0 ; i < b .N ; i ++ {
1380
1372
dmp .DiffMain (s1 , s2 , true )
1381
1373
}
1382
1374
}
1383
1375
1376
+ func Benchmark_DiffMainLargeLines (b * testing.B ) {
1377
+ s1 := readFile ("speedtest1.txt" , b )
1378
+ s2 := readFile ("speedtest2.txt" , b )
1379
+ dmp := New ()
1380
+ b .ResetTimer ()
1381
+ for i := 0 ; i < b .N ; i ++ {
1382
+ text1 , text2 , linearray := dmp .DiffLinesToChars (s1 , s2 )
1383
+ diffs := dmp .DiffMain (text1 , text2 , false )
1384
+ diffs = dmp .DiffCharsToLines (diffs , linearray )
1385
+ }
1386
+ }
1387
+
1388
+ func readFile (filename string , b * testing.B ) string {
1389
+ bytes , err := ioutil .ReadFile (filename )
1390
+ if err != nil {
1391
+ b .Fatal (err )
1392
+ }
1393
+ return string (bytes )
1394
+ }
1395
+
1396
+
1384
1397
1385
1398
1386
1399
You can’t perform that action at this time.
0 commit comments