tests/test-diff-antipatience.t
author Yuya Nishihara <yuya@tcha.org>
Mon, 12 Mar 2018 20:45:10 +0900
changeset 37064 434e520adb8c
parent 36678 7834927f0243
child 38469 9ef9884e5d50
permissions -rw-r--r--
annotate: do not construct attr.s object per line while computing history Unfortunately, good abstraction has a cost. It's way slower to construct an annotateline() object than creating a plain tuple or a list. This patch changes the internal data structure from row-based to columnar, so the decorate() function can be instant (i.e. no Python in hot loop.) For code readability, the outermost tuple is switched to an attr.s object instead. (original, row-based attr.s) $ hg annot mercurial/commands.py --time > /dev/null time: real 11.470 secs (user 11.400+0.000 sys 0.070+0.000) $ hg annot mercurial/commands.py --time --line-number > /dev/null time: real 39.590 secs (user 39.500+0.000 sys 0.080+0.000) (this patch, columnar) $ hg annot mercurial/commands.py --time > /dev/null time: real 11.780 secs (user 11.710+0.000 sys 0.070+0.000) $ hg annot mercurial/commands.py --time --line-number > /dev/null time: real 12.240 secs (user 12.170+0.000 sys 0.090+0.000) (cf. 4.3.3, row-based tuple) $ hg annot mercurial/commands.py --time --line-number > /dev/null time: real 19.540 secs (user 19.460+0.000 sys 0.080+0.000)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36678
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
     1
#testcases bdiff xdiff
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
     2
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
     3
#if xdiff
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
     4
#require xdiff
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
     5
  $ cat >> $HGRCPATH <<EOF
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
     6
  > [experimental]
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
     7
  > xdiff = true
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
     8
  > EOF
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
     9
#endif
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    10
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    11
Test case that makes use of the weakness of patience diff algorithm
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    12
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    13
  $ hg init
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    14
  >>> open('a', 'wb').write(b'\n'.join(list(b'a' + b'x' * 10 + b'u' + b'x' * 30 + b'a\n')))
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    15
  $ hg commit -m 1 -A a
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    16
  >>> open('a', 'wb').write(b'\n'.join(list(b'b' + b'x' * 30 + b'u' + b'x' * 10 + b'b\n')))
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    17
#if xdiff
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    18
  $ hg diff
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    19
  diff -r f0aeecb49805 a
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    20
  --- a/a	Thu Jan 01 00:00:00 1970 +0000
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    21
  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    22
  @@ -1,4 +1,4 @@
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    23
  -a
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    24
  +b
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    25
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    26
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    27
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    28
  @@ -9,7 +9,6 @@
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    29
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    30
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    31
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    32
  -u
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    33
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    34
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    35
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    36
  @@ -30,6 +29,7 @@
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    37
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    38
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    39
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    40
  +u
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    41
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    42
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    43
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    44
  @@ -40,5 +40,5 @@
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    45
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    46
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    47
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    48
  -a
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    49
  +b
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    50
   
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    51
#else
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    52
  $ hg diff
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    53
  diff -r f0aeecb49805 a
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    54
  --- a/a	Thu Jan 01 00:00:00 1970 +0000
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    55
  +++ b/a	Thu Jan 01 00:00:00 1970 +0000
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    56
  @@ -1,15 +1,4 @@
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    57
  -a
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    58
  -x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    59
  -x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    60
  -x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    61
  -x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    62
  -x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    63
  -x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    64
  -x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    65
  -x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    66
  -x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    67
  -x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    68
  -u
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    69
  +b
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    70
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    71
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    72
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    73
  @@ -40,5 +29,16 @@
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    74
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    75
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    76
   x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    77
  -a
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    78
  +u
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    79
  +x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    80
  +x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    81
  +x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    82
  +x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    83
  +x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    84
  +x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    85
  +x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    86
  +x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    87
  +x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    88
  +x
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    89
  +b
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    90
   
7834927f0243 tests: add tests about diff quality
Jun Wu <quark@fb.com>
parents:
diff changeset
    91
#endif