FLTK logo

[fltk.general] Slow response when calling Fl_Text_Editor::buffer()

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.general  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Slow response when calling Fl_Text_Editor::buffer() Eric Sokolowsky 06:43 Apr 19  
 
I have been experiencing slow performance when using Fl_Text_Editor in my application. I see a significant delay (some 7 seconds) when calling Fl_Text_Editor::buffer on a new Fl_Text_Buffer when my application starts. Is this normal behavior? I'm just so used to FLTK working almost instantly for every operation that this was surprising to me. I'm using FLTK 1.3.4 because I cannot right now move to a newer version of FLTK, because of system dependencies. Here's a snippet of the code I use, together with some debugging output so I could tell why it was being slow:


int w = 800;  // width of window
int h = 25;   // height of one widget
int m = 10;    // blank margin
int sw = 80;   // standard width
Fl_Double_Window *main_window = new Fl_Double_Window(w, 615, hw::progname().c_str());
ypos += h + 5;
Fl_Text_Editor *caption_text = new Fl_Text_Editor(xpos, ypos, w - xpos - m, 5*h, "Caption Text: ");
std::cout << "Checkpoint 5.2.1: " << timer.elapsed() << "\n";
caption_text->align(FL_ALIGN_LEFT);
std::cout << "Checkpoint 5.2.2: " << timer.elapsed() << "\n";
caption_text->callback((Fl_Callback*) cb_caption_text, &show);
std::cout << "Checkpoint 5.2.3: " << timer.elapsed() << "\n";
caption_text->when(FL_WHEN_CHANGED);
std::cout << "Checkpoint 5.2.4: " << timer.elapsed() << "\n";
Fl_Text_Buffer *caption_buf = new Fl_Text_Buffer;
std::cout << "Checkpoint 5.2.5: " << timer.elapsed() << "\n";
caption_text->buffer(caption_buf);
std::cout << "Checkpoint 5.2.6: " << timer.elapsed() << "\n";
caption_text->wrap_mode(Fl_Text_Editor::WRAP_AT_BOUNDS, 5);
std::cout << "Checkpoint 5.2.7: " << timer.elapsed() << "\n";

Here's some of the output:

Checkpoint 1: 0.0038885
Checkpoint 2: 0.00390178
Checkpoint 3: 0.00391342
Checkpoint 4: 0.00393642
Checkpoint 5: 0.00394311
Checkpoint 5.1: 0.00394802
Checkpoint 5.2: 0.00395305
Checkpoint 5.2.1: 0.00396602
Checkpoint 5.2.2: 0.00397152
Checkpoint 5.2.3: 0.0039758
Checkpoint 5.2.4: 0.00398055
Checkpoint 5.2.5: 0.00399762
Checkpoint 5.2.6: 6.98275
Checkpoint 5.2.7: 6.98277
Checkpoint 5.3: 6.98278
Checkpoint 6: 6.98278
Checkpoint 7: 6.9828

As you can see, the delay comes from the line where the editor is given the text buffer to use. Everything else is fast, as expected.

Any light that could be shed on this would be appreciated.

Eric

--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkgeneral/CAPiqgzM58O6KB5EjcP-Vs_5%3DvYJpB6W8N8Xq103HD_cZN60bEg%40mail.gmail.com.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.