Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a real performance gain when I turn {$IMPORTEDDATA} off?

Is there a real performance gain when I turn {$IMPORTEDDATA} off ?

The manual only says this: "The {$G-} directive disables creation of imported data references. Using {$G-} increases memory-access efficiency, but prevents a packaged unit where it occurs from referencing variables in other packages."


Update:

Here is more info I could find:

"The Debugging section has the new option Use imported data references (mapped to $G), which controls the creation of imported data references (increasing memory efficiency but preventing the access of global variables defined in other runtime packages)"

like image 695
thelight Avatar asked Oct 10 '22 21:10

thelight


1 Answers

Almost never

This directive only refers to accessing global unit variables from another unit.

If you use {$G+}

unit1;

interface

var
  Global1: integer;   //<--  this is a global var in unit1.
  Form1: TForm1;      //<--  also a global var, but really a pointer

Global1 will be accessed indirectly via a pointer (if and when accessed from outside unit1)
Form1 will also be accessed indirectly (i.e. change from a direct pointer to an indirect pointer).

if you use {$G-}, the access to integer global will be direct and thus slightly faster.

This will only make a difference if you use global public unit variables in another unit and in time critical code, i.e. almost never.

See this article: http://hallvards.blogspot.com/2006/09/hack13-access-globals-faster.html

like image 171
Johan Avatar answered Oct 16 '22 18:10

Johan