[llvm] r259242 - Improve test speed (interchange loop, reducing padding)

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 29 13:27:58 PST 2016


Done.

David

On Fri, Jan 29, 2016 at 1:22 PM, Sean Silva <chisophugis at gmail.com> wrote:
>
>
> On Fri, Jan 29, 2016 at 1:13 PM, Xinliang David Li via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>>
>> Author: davidxl
>> Date: Fri Jan 29 15:13:55 2016
>> New Revision: 259242
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=259242&view=rev
>> Log:
>> Improve test speed (interchange loop, reducing padding)
>>
>> Modified:
>>     llvm/trunk/unittests/ProfileData/InstrProfTest.cpp
>>
>> Modified: llvm/trunk/unittests/ProfileData/InstrProfTest.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/InstrProfTest.cpp?rev=259242&r1=259241&r2=259242&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/unittests/ProfileData/InstrProfTest.cpp (original)
>> +++ llvm/trunk/unittests/ProfileData/InstrProfTest.cpp Fri Jan 29 15:13:55
>> 2016
>> @@ -124,6 +124,45 @@ TEST_F(InstrProfTest, get_function_count
>>    ASSERT_TRUE(ErrorEquals(instrprof_error::unknown_function, EC));
>>  }
>>
>> +// Profile data is copied from general.proftext
>> +TEST_F(InstrProfTest, get_profile_summary) {
>> +  InstrProfRecord Record1("func1", 0x1234, {97531});
>> +  InstrProfRecord Record2("func2", 0x1234, {0, 0});
>> +  InstrProfRecord Record3("func3", 0x1234,
>> +                          {2305843009213693952, 1152921504606846976,
>> +                           576460752303423488, 288230376151711744,
>> +                           144115188075855872, 72057594037927936});
>> +  InstrProfRecord Record4("func4", 0x1234, {0});
>> +  Writer.addRecord(std::move(Record1));
>> +  Writer.addRecord(std::move(Record2));
>> +  Writer.addRecord(std::move(Record3));
>> +  Writer.addRecord(std::move(Record4));
>> +  auto Profile = Writer.writeBuffer();
>> +  readProfile(std::move(Profile));
>> +
>> +  ProfileSummary &PS = Reader->getSummary();
>> +  ASSERT_EQ(2305843009213693952U, PS.getMaxFunctionCount());
>> +  ASSERT_EQ(2305843009213693952U, PS.getMaxBlockCount());
>> +  ASSERT_EQ(10U, PS.getNumBlocks());
>> +  ASSERT_EQ(4539628424389557499U, PS.getTotalCount());
>> +  std::vector<ProfileSummaryEntry> &Details = PS.getDetailedSummary();
>> +  uint32_t Cutoff = 800000;
>> +  auto Predicate = [&Cutoff](const ProfileSummaryEntry &PE) {
>> +    return PE.Cutoff == Cutoff;
>> +  };
>> +  auto EightyPerc = std::find_if(Details.begin(), Details.end(),
>> Predicate);
>> +  Cutoff = 900000;
>> +  auto NinetyPerc = std::find_if(Details.begin(), Details.end(),
>> Predicate);
>> +  Cutoff = 950000;
>> +  auto NinetyFivePerc = std::find_if(Details.begin(), Details.end(),
>> Predicate);
>> +  Cutoff = 990000;
>> +  auto NinetyNinePerc = std::find_if(Details.begin(), Details.end(),
>> Predicate);
>> +  ASSERT_EQ(576460752303423488U, EightyPerc->MinBlockCount);
>> +  ASSERT_EQ(288230376151711744U, NinetyPerc->MinBlockCount);
>> +  ASSERT_EQ(288230376151711744U, NinetyFivePerc->MinBlockCount);
>> +  ASSERT_EQ(72057594037927936U, NinetyNinePerc->MinBlockCount);
>> +}
>> +
>>  TEST_F(InstrProfTest, get_icall_data_read_write) {
>>    InstrProfRecord Record1("caller", 0x1234, {1, 2});
>>    InstrProfRecord Record2("callee1", 0x1235, {3, 4});
>> @@ -716,20 +755,20 @@ TEST_F(InstrProfTest, instr_prof_symtab_
>>      FuncNames2.push_back(OS.str());
>>    }
>>
>> -  for (int Padding = 0; Padding < 10; Padding++) {
>> -    for (int DoCompression = 0; DoCompression < 2; DoCompression++) {
>> -      // Compressing:
>> -      std::string FuncNameStrings1;
>> -      collectPGOFuncNameStrings(FuncNames1,
>> -                                (DoCompression != 0 &&
>> zlib::isAvailable()),
>> -                                FuncNameStrings1);
>> -
>> -      // Compressing:
>> -      std::string FuncNameStrings2;
>> -      collectPGOFuncNameStrings(FuncNames2,
>> -                                (DoCompression != 0 &&
>> zlib::isAvailable()),
>> -                                FuncNameStrings2);
>> +  for (int DoCompression = 0; DoCompression < 2; DoCompression++) {
>
>
> Would something like this work?
> for (bool DoCompression : {false, true}) ...
>
> -- Sean Silva
>
>>
>> +    // Compressing:
>> +    std::string FuncNameStrings1;
>> +    collectPGOFuncNameStrings(FuncNames1,
>> +                              (DoCompression != 0 &&
>> zlib::isAvailable()),
>> +                              FuncNameStrings1);
>> +
>> +    // Compressing:
>> +    std::string FuncNameStrings2;
>> +    collectPGOFuncNameStrings(FuncNames2,
>> +                              (DoCompression != 0 &&
>> zlib::isAvailable()),
>> +                              FuncNameStrings2);
>>
>> +    for (int Padding = 0; Padding < 3; Padding++) {
>>        // Join with paddings:
>>        std::string FuncNameStrings = FuncNameStrings1;
>>        for (int P = 0; P < Padding; P++) {
>> @@ -743,7 +782,8 @@ TEST_F(InstrProfTest, instr_prof_symtab_
>>
>>        // Now do the checks:
>>        // First sampling some data points:
>> -      StringRef R =
>> Symtab.getFuncName(IndexedInstrProf::ComputeHash(FuncNames1[0]));
>> +      StringRef R =
>> +
>> Symtab.getFuncName(IndexedInstrProf::ComputeHash(FuncNames1[0]));
>>        ASSERT_EQ(StringRef("func_0"), R);
>>        R =
>> Symtab.getFuncName(IndexedInstrProf::ComputeHash(FuncNames1[1]));
>>        ASSERT_EQ(StringRef("fooooooooooooooo_0"), R);
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>


More information about the llvm-commits mailing list