head	1.6;
access
	monica
	thoth;
symbols
	Eglin_alpha_1:1.3;
locks
	monica:1.6; strict;
comment	@// @;


1.6
date	94.11.09.20.25.21;	author monica;	state Exp;
branches;
next	1.5;

1.5
date	94.10.06.01.07.08;	author monica;	state Exp;
branches;
next	1.4;

1.4
date	94.08.17.04.12.11;	author monica;	state Exp;
branches;
next	1.3;

1.3
date	93.01.20.11.39.59;	author thoth;	state Exp;
branches;
next	1.2;

1.2
date	92.12.15.21.18.24;	author thoth;	state Exp;
branches;
next	1.1;

1.1
date	92.10.07.22.46.07;	author thoth;	state Exp;
branches;
next	;


desc
@binary pointset operation performance test
@


1.6
log
@removed include devfrags & any debugging calls to malloc
@
text
@// Emacs: -*- C++ -*-
static char rcsid[] = "$Id: test009.c,v 1.5 1994/10/06 01:07:08 monica Exp monica $";

//
// $Log: test009.c,v $
// Revision 1.5  1994/10/06  01:07:08  monica
// updated for DOS file naming
//
// Revision 1.4  1994/08/17  04:12:11  monica
// added int main & return 0
//
// Revision 1.3  1993/01/20  11:39:59  thoth
// we now use the Random_PS instead of the function.
//
// Revision 1.2  92/12/15  21:18:24  thoth
// ifdefed print statements.
// 
// Revision 1.1  92/10/07  22:46:07  thoth
// Initial revision
// 
//

#include <stdlib.h>
#include <sys/time.h>
#include <sys/resource.h>

#include "IntPoint.h"
#include "IntPS.h"
#include "PSIter.h"

#include "gen-test.h"
#include "pt-util.h"
#include "ps-util.h"
#include "tutil.h"

extern "C" {
    double drand48();
}

double	density;

int bullshit(const IA_Point<int> &) {
    return drand48()<density;
}

int main(int argc, char**argv)
{
    unsigned choice, size, width, ntimes;
    unsigned idx=0;

    idx++; choice = (argc<idx+1) ? -1 : atoi(argv[idx]);
    idx++; size = (argc<idx+1) ? 2 : atoi(argv[idx]);
    idx++; width = (argc<idx+1) ? 512 : atoi(argv[idx]);
    idx++; density = (argc<idx+1) ? 0.5 : atof(argv[idx]);
    idx++; ntimes = (argc<idx+1) ? 1 : atoi(argv[idx]);

    IA_Set<IA_Point<int> > (*f)(const IA_Set<IA_Point<int> >&,const IA_Set<IA_Point<int> >&);
    char	*desc;

    switch (choice) {
    case 0:
	f = operator&;
	desc = "intersection";
	break;
    case 1:
	f = operator|;
	desc = "union";
	break;
    case 2:
	f = operator^;
	desc = "XOR";
	break;
    case 3:
	f = operator/;
	desc = "difference";
	break;
    default:
	cerr << "please make a choice (argv[1] must be 0..3)\n";
	exit(1);
    }

    IA_Point<int>	inf_(extend_to_point((int)0,(int)size));
    IA_Point<int>	sup_(extend_to_point((int)width-1,(int)size));
    IA_Set<IA_Point<int> > ps(inf_,sup_);

    struct rusage	now, later;
    double	dt;

#if 0
    IA_Set<IA_Point<int> >	ps1(size,bullshit), ps2(size,bullshit);
#else
    IA_Set<IA_Point<int> >	ps1(Random_PS(size,density)), ps2(Random_PS(size,density));
#endif

    getrusage(RUSAGE_SELF ,&now);
    ps1 &= ps;
    ps2 &= ps;
    getrusage(RUSAGE_SELF ,&later);
    dt = (Ttof(later.ru_utime)- Ttof(now.ru_utime));
#ifdef VERBOSE
    cout << "lazy, boxy intersections took " << dt << " seconds (cards "
	 << ps1.card() << " and " << ps2.card() << ")\n";
#endif

    unsigned	i;

    getrusage(RUSAGE_SELF ,&now);
    for (i=0; i<ntimes; i++) {
	f(ps1,ps2);
    }
    getrusage(RUSAGE_SELF ,&later);
    dt = (Ttof(later.ru_utime)- Ttof(now.ru_utime));
#ifdef VERBOSE
    cout << "Yoders card = " << ps1.card() << "," << ps2.card() << "  : ";
    cout << dt << " seconds\n";
#endif
    cout << ( ntimes / dt ) << " " << desc;
#ifdef VERBOSE
    cout << "s/second\n";
#else
    cout << " ";
#endif
    cout << ( ntimes*(ps1.card()+ps2.card()) / dt );
#ifdef VERBOSE
    cout << " points/second (ps1.card + ps2.card)\n";
#endif

    return 0;

}
@


1.5
log
@updated for DOS file naming
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: test009.c,v 1.4 1994/08/17 04:12:11 monica Exp monica $";
d6 3
a26 1
#include "devfrags.h"
@


1.4
log
@added int main & return 0
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: test009.c,v 1.3 1993/01/20 11:39:59 thoth Exp monica $";
d6 3
d24 1
a24 1
#include "dev-frags.h"
d29 3
a31 3
#include "generic-tests.h"
#include "point-utils.h"
#include "pointset-utils.h"
@


1.3
log
@we now use the Random_PS instead of the function.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: test009.c,v 1.2 92/12/15 21:18:24 thoth Exp Locker: thoth $";
d5 4
a8 1
// $Log:	test009.c,v $
d23 2
a24 2
#include "IntPointSet.h"
#include "IPSIter.h"
d37 1
a37 1
int bullshit(const IntPoint &) {
d52 1
a52 1
    IntPointSet (*f)(const IntPointSet&,const IntPointSet&);
d77 3
a79 3
    IntPoint	inf_(extend_to_point(0,size));
    IntPoint	sup_(extend_to_point(width-1,size));
    IntPointSet ps(inf_,sup_);
d85 1
a85 1
    IntPointSet	ps1(size,bullshit), ps2(size,bullshit);
d87 1
a87 1
    IntPointSet	ps1(Random_PS(size,density)), ps2(Random_PS(size,density));
d122 3
@


1.2
log
@ifdefed print statements.
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: test009.c,v 1.1 92/10/07 22:46:07 thoth Exp Locker: thoth $";
d6 3
d81 1
d83 3
@


1.1
log
@Initial revision
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: test004.c,v 1.5 92/09/20 17:42:54 thoth Exp $";
d5 4
a8 1
// $Log:	test004.c,v $
d85 1
d88 1
d98 1
d101 11
a111 2
    cout << ( ntimes / dt ) << " " << desc << "s/second\n";
    cout << ( ntimes*(ps1.card()+ps2.card()) / dt ) << " points/second (ps1.card + ps2.card)\n";
@
