Often a D program is easier to read if you break up a complex predicate
into separate clauses, but I was wondering if you sacrifice script
performance to do that.  For example, the following two D programs do
the same thing (Do a 20 second interval quantize of pread/pwrite block
sizes for a specific Oracle DB instance).  Clearly "ora1.d" is easier to
read, but is "ora2.d" more efficient?

 

# cat ora1.d

#!/usr/sbin/dtrace -s

 

/*

   Quantize IO blocksize for Oracle random I/O

   for specific DB instance.

*/

 

#pragma D option quiet

 

inline string parmDBinst = $$1;

 

syscall::pread*:entry,

syscall::pwrite*:entry

/ execname == "oracle" /

{

   this->cmd = strtok(curpsinfo->pr_psargs, " ");

   this->dbinst =

      (substr(this->cmd,0,6) == "oracle") ? substr(this->cmd,6) :

      (substr(this->cmd,0,4) == "ora_" ? substr(this->cmd,9) :
"noDBnoDB");

}

 

syscall::pread*:entry,

syscall::pwrite*:entry

/ this->dbinst == parmDBinst /

{

   @IO[probefunc] = quantize(arg2);

}

 

tick-20s,END

{

   printf ("%Y\n", walltimestamp);

   printa (@IO);

   clear (@IO);

}

# cat ora2.d

#!/usr/sbin/dtrace -s

 

/*

   Quantize IO blocksize for Oracle random I/O

   for specific DB instance.

*/

 

#pragma D option quiet

 

inline string parmDBinst = $$1;

 

syscall::pread*:entry,

syscall::pwrite*:entry

/ execname == "oracle" &&

    (this->cmd = strtok(curpsinfo->pr_psargs, " "),

     parmDBinst == ((substr(this->cmd,0,6) == "oracle") ?
substr(this->cmd,6) :

        (substr(this->cmd,0,4) == "ora_" ? substr(this->cmd,9) :
"noDBnoDB"))) /

{

   @IO[probefunc] = quantize(arg2);

}

 

tick-20s,END

{

   printf ("%Y\n", walltimestamp);

   printa (@IO);

   clear (@IO);

}

#

 

Thanks,

Chip Bennett




-----------------------------------------
**************************************************
This e-mail and any of its attachments may contain Exelon
Corporation proprietary information, which is privileged,
confidential, or subject to copyright belonging to the Exelon
Corporation family of Companies. 
This e-mail is intended solely for the use of the individual or
entity to which it is addressed.  If you are not the intended
recipient of this e-mail, you are hereby notified that any
dissemination, distribution, copying, or action taken in relation
to the contents of and attachments to this e-mail is strictly
prohibited and may be unlawful.  If you have received this e-mail
in error, please notify the sender immediately and permanently
delete the original and any copy of this e-mail and any printout.
Thank You.
**************************************************
_______________________________________________
dtrace-discuss mailing list
dtrace-discuss@opensolaris.org

Reply via email to