timing for \copy

Started by Andrew Dunstanalmost 20 years ago3 messagespatches
Jump to latest
#1Andrew Dunstan
andrew@dunslane.net

The attached patch implements timing for psql's \copy command, the
absence of which I have whined about previously.

If there's no objection I will apply this in a few days. I'm not sure
that a docs change is needed.

cheers

andrew

Attachments:

timingdifftext/plain; name=timingdiffDownload+43-26
#2Neil Conway
neilc@samurai.com
In reply to: Andrew Dunstan (#1)
Re: timing for \copy

On Wed, 2006-12-13 at 11:36 -0500, Andrew Dunstan wrote:

+ 		if (pset.timing)
+ 		{
+ 			GETTIMEOFDAY(&after);
+ 			elapsed_msec = DIFF_MSEC(&after, &before);
+ 			if (success)
+ 				printf(_("Time: %.3f ms\n"), elapsed_msec);
+ 
+ 		}

Not exactly a big deal, but

if (pset.timing && success)
{
/* ... */
}

seems a bit clearer, and avoids unnecessary work on failure. You can
also move "elapsed_msec" and "after" inside the "if" block.

Also, I believe headers should #include the headers that they themselves
depend on, so the inclusion of the getttimeofday() or _ftime() headers
could be moved to common.h

-Neil

#3Andrew Dunstan
andrew@dunslane.net
In reply to: Neil Conway (#2)
Re: timing for \copy

Neil Conway wrote:

You can
also move "elapsed_msec" and "after" inside the "if" block.

Thanks.

I'll do the other stuff, but I prefer to keep related declarations
together. I'm not a huge fan of blindly pushing every declaration to the
lowest level possible.

I'll commit after I have made sure it works on Windows.

cheers

andrew