tacle / tacle-bench

TACLe Benchmarks
41 stars 38 forks source link

Insertsort test mistake #22

Closed franhans closed 3 years ago

franhans commented 4 years ago

Function insertsort_initialize does not initialize the last element of insertsort_a array. Therefore, insertsort_a[10] is not always 0 as it should be to work properly obatining a checksum of 52. If insertsort_a[10] is for example, bigger than 11, the checksum is 63 instead of 52.

schirmeier commented 3 years ago

It is true that insertsort_initialize does not initialize insertsort_a[10] with a[10] (which holds the value 2). However, insertsort_a is a global variable and by definition filled with zeroes at program start (so insertsort_a[10] holds 0 instead of 2), so the benchmark is deterministic.

There seems to be more at fault, though: Initialization only copies 10 values (indexes 0 through 9), sorting happens including the 11th value (index 10), checksumming again only adds up the first 10 values (excluding value 11 sorted to index 10). This explains why the tested-for sum in insertsort_return() is 52, not 54 or 65.