Autor Beitrag
Red-Flash
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18
Erhaltene Danke: 1



BeitragVerfasst: Fr 02.07.10 07:13 
Wenn ich Komponenten (Checkboxen, Comboboxen) dynamisch erzeugen will, CheckBox1 [i] := TChecbox.Create (... in einer Schleife hatte ich unter Win XP keine Probleme. Unter Vista wurde es schon langsam, ABER unter Windows 7 ist es unerträglich.

Wenn ich Z.B Combobox Einträge übergeben will dies 40 hal hintereinander
ausblenden Delphi-Quelltext
1:
Combobox1.Items.Assign (Combobox2.Items);					
dauert es un die 14 sek... dies ist auch unerträglich langsam Unter XP 2 sek

Weiß jemand zufällig was ich da tun kann (irgendwas im Windows abstellen oder so)

danke schon mal

Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
Moderiert von user profile iconNarses: Überflüssige Zeilenumbrüche/Leerzeilen entfernt.
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Fr 02.07.10 08:05 
Warum das so ist weiß ich leider auch nicht, dazu müsste man wohl etwas mehr Code sehen. Bei den ComboBoxen könntest du etwas Zeit gewinnen in dem du BeginUpdate und EndUpdate verwendest:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
  ComboBox1.Items.BeginUpdate;
  try
    //Hier Items kopieren oder was auch immer...
  finally
    ComboBox1.Items.EndUpdate;
  end;
Red-Flash Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18
Erhaltene Danke: 1



BeitragVerfasst: Fr 02.07.10 08:21 
Begin und EndUpdate bringt leider nix

Was für Quelltext willst du ?

Wie man ne Komponente erzeugt ?
oder wie mam ca. 30 Items von einer Box an 40 andere Boxen weitergeben will ?
Tastaro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 414
Erhaltene Danke: 23



BeitragVerfasst: Fr 02.07.10 08:49 
Ich sage mal: Am Windows liegt es nicht.
Deine Beobachtungen sind nicht aussagekräftig, da sich außer dem Betriebssystem wahrscheinlich auch noch andere Dinge geändert haben (z.B. der PC).

Was tust du mit den Checkboxen? Werden die nur erzeugt? Wird das Formular während dem Erzeugen angezeigt? Werden sie noch initialisiert (vielleicht mehrfach).

Wenn du nicht mehr Information rausgeben möchtest, dann kann ich dir nur dazu raten eine schnelleren Computer zu kaufen. Das sollte helfen.

Beste Grüße
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Fr 02.07.10 08:52 
Ist das mit oder ohne AeroGlass? Welches Delphi? Mit oder ohne Manifest?

Kann gut sein, dass der DM da immer sinnlos neu zeichnet. Dann würde es vielleicht helfen, das Fenster erst anzuzeigen, wenn alles fertig ist.

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
Red-Flash Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18
Erhaltene Danke: 1



BeitragVerfasst: Fr 02.07.10 10:48 
Windows 7
Delphi 5

Aero habe ich auch schon abgeschaltet (ohne Erfolg)

Das ganze passiert im Formshow (also ist nich alles unsichtbar), die Combos habe vorher schon auf Visible False gesetzt

Alles ohne Erfolg.

Ich denke auch das da was sinnloses (Zeichnen..Aero) im Hintergrund passiert, aber wie kann ich ihm das abgewöhnen ?????

Moderiert von user profile iconNarses: Überflüssige Zeilenumbrüche/Leerzeilen entfernt.
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Fr 02.07.10 10:53 
wenn Du wirklich die GDI im Verdacht hast
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
  LockwindowUpdate(handle);
  try
    TuwasDuWillst;
  finally
    LockwindowUpdate(nil);
  end;
Red-Flash Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18
Erhaltene Danke: 1



BeitragVerfasst: Fr 02.07.10 11:09 
Habe jetzt noch folgendes probiert

1
In den Anzeigeeinstellungen Windows Classic ausgewählt
KEINEN Erfolg

2
In den Leistungsoptionen/Visuelle Efekte
>>>Für optimale Leistung anpassen<<< eingestellt
KEINEN Erfolg


3.
LockwindowUpdate(Application.handle);
try
TuwasDuWillst;
finally
LockwindowUpdate(0);
end;

Leider auch KEINEN Erfolg


Will wieder XP haben.....
Tastaro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 414
Erhaltene Danke: 23



BeitragVerfasst: Fr 02.07.10 11:57 
Dein 3 stimmt nicht mit dem Vorschlag von Bummi überein.

Beste Grüße

edit:

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
procedure TfMain.FormCreate(Sender: TObject);
var
   cbTest0: tcombobox;
   cbTest: tcombobox;
   chbTest: tcheckbox;
   iZaehl: integer;
   lwStart: longword;
   lwTime: longword;
begin
   lwStart := gettickcount;
   cbTest0 := tcombobox.create(Self);
   cbTest0.Parent := Self;
   cbTest0.Items.beginupdate;
   for iZaehl := 1 to 1000 do
      cbTest0.Items.add(inttostr(iZaehl));
   cbTest0.Items.endupdate;
   lwTime := gettickcount - lwStart;
   showmessage(inttostr(lwTime));
   lwStart := gettickcount;
   for iZaehl := 1 to 100 do
   begin
      cbTest := tcombobox.create(Self);
      cbTest.Parent := Self;
      cbTest.Items.beginupdate;
      //assign ist langsamer als die Zuweisung
      //cbTest.Items.assign(cbTest0.Items);
      cbTest.Items.Text := cbTest0.Text;
      cbTest.Items.endupdate;
   end;
   lwTime := gettickcount - lwStart;
   showmessage(inttostr(lwTime));
   lwStart := gettickcount;
   for iZaehl := 1 to 100 do
   begin
      chbTest := tcheckbox.create(Self);
      chbTest.Parent := Self;
   end;
   lwTime := gettickcount - lwStart;
   showmessage(inttostr(lwTime));
end;


Meine Werte: 47 - 437 - 0
Red-Flash Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18
Erhaltene Danke: 1



BeitragVerfasst: Fr 02.07.10 14:17 
Bei meinem Problem hat

cbTest.Items.Text := cbTest0.Text;

leider nix gebracht..


Meine Werte

46 1997 421


System
Win 7 Ultimate
CPU Intel Core 2 Duo 3GHz
RAM 2 GB

sollte nicht zur langsamen Sorte gehören..
Red-Flash Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18
Erhaltene Danke: 1



BeitragVerfasst: Mi 07.07.10 07:05 
@Tastaro

was für ein OS hast du?
auch win 7
Tastaro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 414
Erhaltene Danke: 23



BeitragVerfasst: Mi 07.07.10 08:51 
Die Zahlen waren von einem Vista-System.

Habe es grad mal mit XP und Win7 getestet. Die Variante mit der Zuweisung (nicht assign)
XP: 16, 125, 0
Win7: 63, 1202, 16
Bin ziemlich überrascht. So große Unterschiede hätte ich nicht erwartet. Spannend. Muss mal etwas forschen, wenn ich die Zeit finde.

Beste Grüße


Edit:
Mein Programm hat einen kleinen Fehler

procedure TfMain.Form
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
Create(Sender: TObject);
var
   cbTest0: tcombobox;
   cbTest: tcombobox;
   chbTest: tcheckbox;
   iZaehl: integer;
   lwStart: longword;
   lwTime: longword;
begin
   lwStart := gettickcount;
   cbTest0 := tcombobox.create(Self);
   cbTest0.Parent := Self;
   cbTest0.Items.beginupdate;
   for iZaehl := 1 to 1000 do
      cbTest0.Items.add(inttostr(iZaehl));
   cbTest0.Items.endupdate;
   lwTime := gettickcount - lwStart;
   showmessage(inttostr(lwTime));
   lwStart := gettickcount;
   for iZaehl := 1 to 100 do
   begin
      cbTest := tcombobox.create(Self);
      cbTest.Parent := Self;
      cbTest.Items.beginupdate;
      //assign ist langsamer als die Zuweisung
      //cbTest.Items.assign(cbTest0.Items);
      cbTest.Items.Text := cbTest0.<span style="color: orange">Items.</span>Text;
      cbTest.Items.endupdate;
   end;
   lwTime := gettickcount - lwStart;
   showmessage(inttostr(lwTime));
   lwStart := gettickcount;
   for iZaehl := 1 to 100 do
   begin
      chbTest := tcheckbox.create(Self);
      chbTest.Parent := Self;
   end;
   lwTime := gettickcount - lwStart;
   showmessage(inttostr(lwTime));
end;


Damit habe ich folgende Werte:
XP: 0, 3469, 0
Vista: 47, 14149, 0
Win7: 47, 3712, 0

hmmmmmmmmmmmmmmmm....


Zuletzt bearbeitet von Tastaro am Mi 07.07.10 09:06, insgesamt 1-mal bearbeitet
Red-Flash Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18
Erhaltene Danke: 1



BeitragVerfasst: Mi 07.07.10 08:59 
Einerseits bin ich Froh, das nicht nur ich das Problem habe,

andererseit finde ich SCH.... das es dieses Problem überhaupt gibt.

Darf ich erfahren in welche Forschrichtung du gehen willst ?
vieleicht kann ich ein wenig unterstützen,

denn monentan bin ich mit meinen Delphi (Latein) am Ende.
Denn mehr wie im Windows den ganzen Schnick-Schnack abstellen kann ich erst mal nicht :-(

Für diesen Beitrag haben gedankt: uko
uko
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 220
Erhaltene Danke: 1

Win XP, VISTA, WIndows 7
Delphi 2007/2010 Prof
BeitragVerfasst: Mi 07.07.10 09:53 
user profile iconTastaro hat folgendes geschrieben Zum zitierten Posting springen:

Damit habe ich folgende Werte:
XP: 0, 3469, 0
Vista: 47, 14149, 0
Win7: 47, 3712, 0

hmmmmmmmmmmmmmmmm....


Hab's grad mal mit deinem Code unter Win7/64 laufen lassen (Delphi 2007):
47, 13463, 0
Gerd Kayser
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 632
Erhaltene Danke: 121

Win 7 32-bit
Delphi 2006/XE
BeitragVerfasst: Mi 07.07.10 11:50 
Ich komme hier auf folgende Werte:
1. Variante: 0 - 281 - 0
2. Variante: 0 - 2215 - 31

Zu meinem System:
Intel-QuadCore-Cpu mit 2,93 GHz, 4 GB Ram, BDS 2006, Windows 7 Ultimate 32 Bit, NVidia Geforce 8800 GTX, Windows-Leistungsindex 5,9, Desktopauflösung 1600 * 1200
Aero ist bei mir aktiviert, auch alle anderen Windows-Spielereien. Das einzige, was ich hier abgewürgt habe, ist die Benutzerkontensteuerung. Im Hintergrund läuft immer McAfee Total Protection mit.
trm
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 491
Erhaltene Danke: 19

Windows 7x64
Delphi 7
BeitragVerfasst: Mi 07.07.10 12:51 
Huhu,

Windows 7x64 (Leistungsindex=5,3) AMD 64 X2 4800+ 2,51 GHz 4GB RAM

OHNE assign (10 Durchläufe):
Durchlauf: 1 1 = 47 2 = 6146 3 = 16
Durchlauf: 2 1 = 15 2 = 5991 3 = 15
Durchlauf: 3 1 = 16 2 = 6536 3 = 16
Durchlauf: 4 1 = 16 2 = 5522 3 = 16
Durchlauf: 5 1 = 31 2 = 5117 3 = 16
Durchlauf: 6 1 = 31 2 = 5694 3 = 31
Durchlauf: 7 1 = 16 2 = 5148 3 = 47
Durchlauf: 8 1 = 47 2 = 5304 3 = 62
Durchlauf: 9 1 = 31 2 = 5351 3 = 109
Durchlauf: 10 1 = 16 2 = 6365 3 = 93



MiT assign (10 Durchläufe):
Durchlauf: 1 1 = 16 2 = 6177 3 = 16
Durchlauf: 2 1 = 16 2 = 5585 3 = 15
Durchlauf: 3 1 = 16 2 = 5070 3 = 15
Durchlauf: 4 1 = 32 2 = 5912 3 = 16
Durchlauf: 5 1 = 31 2 = 5023 3 = 16
Durchlauf: 6 1 = 15 2 = 6396 3 = 62
Durchlauf: 7 1 = 47 2 = 5897 3 = 16
Durchlauf: 8 1 = 31 2 = 7192 3 = 47
Durchlauf: 9 1 = 15 2 = 6724 3 = 47
Durchlauf: 10 1 = 47 2 = 7550 3 = 62



Modifizierter Code für mehrere Durchläufe, ohne die Items vor Neuerstellung zu löschen (Bildaufbau der Form dauert dann ziemlich lange ;)):
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
procedure TForm1.FormCreate(Sender: TObject);
var
   cbTest0: tcombobox;
   cbTest: tcombobox;
   chbTest: tcheckbox;
   iZaehl,x: integer;
   lwStart: longword;
   lwTime: longword;
begin
Memo1.Clear;
Memo1.Lines.Add('');
for x:=1 to 10 do
begin
Memo1.Lines.Add('Durchlauf: '+inttostr(x));
   lwStart := gettickcount;
   cbTest0 := tcombobox.create(Self);
   cbTest0.Parent := Self;
   cbTest0.Items.beginupdate;
   for iZaehl := 1 to 1000 do
      cbTest0.Items.add(inttostr(iZaehl));
   cbTest0.Items.endupdate;
   lwTime := gettickcount - lwStart;
//   showmessage(inttostr(lwTime));
Memo1.Lines[x]:=Memo1.Lines[x]+ '  1 = '+inttostr(lwTime);

   lwStart := gettickcount;
   for iZaehl := 1 to 100 do
   begin
      cbTest := tcombobox.create(Self);
      cbTest.Parent := Self;
      cbTest.Items.beginupdate;
      //assign ist langsamer als die Zuweisung
      cbTest.Items.assign(cbTest0.Items);
      //cbTest.Items.Text := cbTest0.Items.Text;
      cbTest.Items.endupdate;
   end;
   lwTime := gettickcount - lwStart;
//   showmessage(inttostr(lwTime));
Memo1.Lines[x]:=Memo1.Lines[x]+ '  2 = '+inttostr(lwTime);

   lwStart := gettickcount;
   for iZaehl := 1 to 100 do
   begin
      chbTest := tcheckbox.create(Self);
      chbTest.Parent := Self;
   end;
   lwTime := gettickcount - lwStart;
//   showmessage(inttostr(lwTime));
Memo1.Lines[x]:=Memo1.Lines[x]+ '  3 = '+inttostr(lwTime);
end;
end;
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 07.07.10 13:32 
bummi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1248
Erhaltene Danke: 187

XP - Server 2008R2
D2 - Delphi XE
BeitragVerfasst: Mi 07.07.10 13:44 
eine ebenfalls recht flotte Methode wäre:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
const
  MAX = 1000000;
var
  i: Integer;
  Start: Integer;
  s:String;
begin
   Listbox1.Clear;
   Start := GetTickCount;
   for i := 0 to MAX - 1 do s := s+ IntToStr(i) +#13#10;
   ListBox1.Items.Text := s;
  ShowMessage(IntToStr(GetTickCount - Start));
end;
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 07.07.10 13:47 
Wobei das Zusammenbasteln von der Zeichenkette suboptimal ist. Das ist ja letztendlich ein Array, was immer wieder vergrößert und umkopiert werden muss. wenn man so was macht, sollte man vorher genügend Speicherplatz anfordern, damit das Kopieren weg fällt.
Tastaro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 414
Erhaltene Danke: 23



BeitragVerfasst: Mi 07.07.10 15:09 
Auf Luckies Hinweis hin hab ich gerade schnel nochmal eine Test mit meiner Prozedur oben gemacht:

ausblenden Delphi-Quelltext
1:
2:
3:
      cbTest.Items.Capacity := 10000;
      for iIndex := 0 to cbTest0.Items.Count - 1 do
         cbTest.Items.add(cbTest0.Items[iIndex]);


ist auf meinem Vista hier schneller als

ausblenden Delphi-Quelltext
1:
      cbTest.Items.Text := cbTest0.Items.Text;					


Beste Grüße