1. °³¹ß/½ÇÇà Ç÷§Æû (1) OS : win10 32 (2) °³¹ßÅø : delphi Rad Studio 10.1 (3) »ç¿ë Database : N/A
2. °³¹ß ÁßÀÎ ÇÁ·Î±×·¥ Testing Áß
¾È³çÇϼ¼¿ä.¼±¹è´ÔµéÀÇ °í°ßÀ» µè°í ½Í½À´Ï´Ù. ¾Æ¹«·¡µµ Ãë¹Ì·Î ÇÏ´Â ¼öÁØÀÌ¶ó ¸¹ÀÌ ºÎÁ·Çؼ¿ä ¤Ð¤Ð
Áú¹®1) stringgrid ¿¡ ±ÛÀ» Ãâ·Â ÇÒ¶§ Performance °¡ ¶Ù¾î³ ¹æ¹ýÀÌ ¾î¶²°ÍÀÌ ÀÖÀ»±î¿ä?
Type Tstudent = record name : string; number : integer; height : integer; weight : integer; end;
private student : Tlist<Tstudent> //generics.collections uses
TForm1 = class(TForm) StringGrid: TStringGrid; procedure FormCreate(Sender: TObject);
Implementation
procedure TForm1.FormCreate(Sender: TObject); begin student := Tlist<Tstudent>.create; end
ÀÌ·±½ÄÀ¸·Î student ¶ó´Â ±¸Á¶Ã¼¸¦ ¸¸µé¾î¼ StringGrid¿¡ ³»¿ëÀ» »Ñ·ÁÁÝ´Ï´Ù.
ÇлýÀÇ ¼ö°¡ 10¸¸¸íÀÌ»óÀÌ µÉ ¼ö ÀÖÀ¸¸ç, ½Ç½Ã°£À¸·Î ÇлýÀÇ ¼ö°¡ Áٱ⵵ ´Ã¾î³ª±âµµ ÇÏ°í, °¢ ÇлýµéÀÇ height °ªµµ º¯°æ µÇ±âµµ Çϴµ¥ ÀÌ·¯ÇÑ »óȲ¼Ó¿¡¼ StringGrid ÀÇ ÇϳªÀÇ ¿¿¡ height °ªÀ» »Ñ·Á ÁÖ·Á°í ÇÕ´Ï´Ù. (½Ç½Ã°£À¸·Î º¯°æ µÇ´Â ³»¿ëÀÌ StringGrid ȸ鿡¼ ¹Ý¿µµÇ¾î º¯°æ µÇ¾î¾ß ÇÕ´Ï´Ù)
Àú´Â ´Ü¼øÈ÷ °ªÀÇ º¯È³ª Çлý ¼ö°¡ ´Ã°í ÁÙÀ» ¶§ ¸¶´Ù loop ¸¦ µ¹·Á¼ ¾Æ·¡¿Í °°ÀÌ ²Ù¹Ì·Á°í ÇÕ´Ï´Ù.
stringGrid.cols[0].beginupdate; for i := 0 to student.count-1 begin stringGrid.cell[0,i] := IntToStr(student.list[i].student.height); end stringGrid.cols[0].endupdate;
ÀÌ·¸°Ô ²Ù¹Ì·Á°í Çϴµ¥ ´õ ÁÁÀº ¹æ¹ýÀÌ ÀÖÀ»±î¿ä? º¯¼öÀÇ ±¸Á¶°¡ ´Þ¶óÁ®µµ »ó°ü ¾ø½À´Ï´Ù.
Áú¹®2) beginupdate ¹× endupdate ¿¡ ´ëÇÑ ³»¿ëÀÔ´Ï´Ù.
stringGrid.cols[0].beginupdate; for i := 0 to student.count-1 begin stringGrid.cell[0,i] := IntToStr(student.list[i].student.height); end stringGrid.cols[0].endupdate;
beginupdate & endupdateÀÇ ±â´ÉÀÌ colume 0 ¿¡¼ ¼¿°ªÀÌ º¯°æÀÌ µÇ´õ¶óµµ ȸ鿡 ½Ç½Ã°£À¸·Î »Ñ¸®Áö ¸»°í loop °¡ ³¡³ª°í endupdate °¡ ½ÇÇà ÇÏ°Ô µÇ¸é ±× ¶§ ȸ鿡 »Ñ¸®¶ó´Â Àǹ̷Π¾Ë°í ÀÖ½À´Ï´Ù. ¸Â³ª¿ä?
±×·¸´Ù¸é
stringGrid.cols[0].beginupdate; stringGrid.cols[1].beginupdate; stringGrid.cols[2].beginupdate;
for i := 0 to student.count-1 begin stringGrid.cell[0,i] := IntToStr(student.list[i].student.height); stringGrid.cell[1,i] := IntTostr(student.list[i].student.weight); stringGrid.cell[2,i] := IntTostr(student.list[i].student.number);
end stringGrid.cols[0].endupdate; stringGrid.cols[1].endupdate; stringGrid.cols[2].endupdate;
ÀÌ·¸°Ô Çϸé cols[1], cols[2]¸¦ Ç߱⠶§¹®¿¡ colume 1, 2 µµ ¼¿°ªÀÌ º¯°æÀÌ µÇ´õ¶ó°í ȸ鿡 ½Ç½Ã°£À¸·Î »Ñ¸®Áö ¾Ê°í endupdate ÀÌÈÄ Çѹø¿¡ ȸéÀ» »Ñ·ÁÁÖ°Ô µÇ´Â°Ç°¡¿ä? (À§ÀÇ »óȲ¿¡¼ stringgrid.col[1].beginupdate, endupdate, stringgrid.col[2].beginupdate, endupdate ´Â ÀÖÀ¸³ª ¾øÀ¸³ª ¼Óµµ°¡ °°´õ¶ó°í¿ä.. ±×·¡¼ Áú¹®À» ÇÏ°Ô µÇ¾ú½À´Ï´Ù)
ÀÌ»óÀÔ´Ï´Ù. ½Ç·ÂÀÌ ºÎÁ·ÇÏ¿©¼ ±âÃÊÀûÀÎ Áú¹®ÀÏ ¼öµµ ÀÖÀ»°Å °°Àºµ¥ Áú¹®À» ¿Ã·È½À´Ï´Ù. °¨»çÇÕ´Ï´Ù.
|