|
|
Sponsor |
Re: pl/pgsql and returns timestamp type: msg#00112db.postgresql.novice
On Tue, Sep 10, 2002 at 07:58:22PM +0200, Terry Yapt wrote: > I am only testing different datatypes. In the example I would like to > know how many time was spent by the function execution. since we were bothered with this too (and measuring outside of function was not an option - we had to test how much particular parts of function takes time, we (friend of mine to be exact) wrote this code: --- getcpuclock.c --- #include <postgres.h> #include <fmgr.h> PG_FUNCTION_INFO_V1(getcpuclock); Datum getcpuclock(PG_FUNCTION_ARGS) { uint64 tsc; asm ( "\n\trdtsc" "\n\tmovl\t%%eax,(%0)" "\n\tmovl\t%%edx,4(%0)" : : "cx" (&tsc) : "ax", "dx" ); PG_RETURN_INT64(tsc); } --- getcpuclock.c --- this compiled into .so, and installed into postgres with CREATE FUNCTION getcpuclock() RETURNS INT8 AS '/home/users/pgdba/work/lib/getcpuclock.so' LANGUAGE 'C'; (or equivalent with corrected paths) will give you function which returns number of processor ticks from last bootup. this is not easily convertible into seconds or anything else, but provides very good accuracy, and is more or less perfect when measuring how much time you spend on different tasks. hope this helps a bit. depesz -- hubert depesz lubaczewski http://www.depesz.pl/ ------------------------------------------------------------------------ Mój Boże, spraw abym milczał, dopóki się nie upewnię, że naprawdę mam coś do powiedzenia. (c) 1998 depesz
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | WAL file size too big, James F. Martin |
|---|---|
| Next by Date: | SIGHUP postmaster, Mark Seftel |
| Previous by Thread: | Re: pl/pgsql and returns timestamp type, Terry Yapt |
| Next by Thread: | Re: pl/pgsql and returns timestamp type, Terry Yapt |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |
Home | sitemap
| advertise | OSDir is
an inevitable website.
|