help-glpk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Performance of the GLPK terminal hook function


From: Andrew Makhorin
Subject: Re: [Help-glpk] Performance of the GLPK terminal hook function
Date: Wed, 15 Sep 2010 13:04:36 +0400

Hi Xypron,

>I implemented the terminal hook function.
>
>My program reads a GMPL file and solves it. The GMPL file contains
>a line
>
>printf "The smallest bag contains %d marbles\n", sum{n in minBag} n;
>
>I get the following output:
>
>hook('Reading model section from marbles.mod...')
>hook('53 lines were read')
>hook('T')
>hook('h')
>hook('e')
>hook(' ')
>hook('s')
>
>Calling the hook function for every single character can cause
>performance problem. I suggest the hook function to be called
>for complete output lines.

Yes, I will correct this. However, in a general context the user-defined hook 
routine should not expect that a complete line is passed to it. If you need to 
increase the performance, you may use some buffering technique in the hook 
routine; for example, if you redirect the output to a slow device, you may 
flush the buffer every time when it becomes full, or when you receive NL, or 
when a time quantum is exceeded (the latter is useful for the terminal).


Andrew Makhorin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]