head	1.4;
access
	monica
	thoth;
symbols
	Eglin_alpha_1:1.1;
locks
	monica:1.4; strict;
comment	@// @;


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

1.3
date	94.10.06.01.07.08;	author monica;	state Exp;
branches;
next	1.2;

1.2
date	94.08.17.04.12.11;	author monica;	state Exp;
branches;
next	1.1;

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


desc
@test of boxy-boxy intersection.
@


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

//
// $Log: test010.c,v $
// Revision 1.3  1994/10/06  01:07:08  monica
// updated for DOS file naming
//
// Revision 1.2  1994/08/17  04:12:11  monica
// added int main & return 0
//
// Revision 1.1  1992/11/04  16:20:26  thoth
// Initial revision
//
//

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

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

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

extern "C" {
    double drand48();
}

int main(int argc, char**argv)
{
    unsigned choice, ntimes;
    int size, width;
    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++; ntimes = (argc<idx+1) ? 100 : 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>	i1(make_random_point(size, 0, width-1));
    IA_Point<int>	s1(make_random_point(size, 0, width-1));
    IA_Set<IA_Point<int> >	ps1(i1,s1);
    IA_Point<int>	i2(make_random_point(size, 0, width-1));
    IA_Point<int>	s2(make_random_point(size, 0, width-1));
    IA_Set<IA_Point<int> >	ps2(i2,s2);

    struct rusage	now, later;
    double	dt, correction;
    double	totalcard;

    unsigned	i;

    totalcard=0;
    getrusage(RUSAGE_SELF ,&now);
    for (i=0; i<ntimes; i++) {
	IA_Point<int>	i1(make_random_point(size, 0, width-1));
	IA_Point<int>	s1(make_random_point(size, 0, width-1));
	IA_Set<IA_Point<int> >	ps1(i1,s1);
	IA_Point<int>	i2(make_random_point(size, 0, width-1));
	IA_Point<int>	s2(make_random_point(size, 0, width-1));
	IA_Set<IA_Point<int> >	ps2(i2,s2);

	totalcard += ps1.card() + ps2.card();
    }
    getrusage(RUSAGE_SELF ,&later);
    totalcard /= ntimes;
    correction = (Ttof(later.ru_utime)- Ttof(now.ru_utime));
    cout << "Boxys card = " << totalcard << "  construction time : ";
    cout << correction << " seconds\n";

    totalcard=0;
    getrusage(RUSAGE_SELF ,&now);
    for (i=0; i<ntimes; i++) {
	IA_Point<int>	i1(make_random_point(size, 0, width-1));
	IA_Point<int>	s1(make_random_point(size, 0, width-1));
	IA_Set<IA_Point<int> >	ps1(i1,s1);
	IA_Point<int>	i2(make_random_point(size, 0, width-1));
	IA_Point<int>	s2(make_random_point(size, 0, width-1));
	IA_Set<IA_Point<int> >	ps2(i2,s2);

	f(ps1,ps2);

	totalcard += ps1.card() + ps2.card();
    }
    getrusage(RUSAGE_SELF ,&later);
    totalcard /= ntimes;
    dt = (Ttof(later.ru_utime)- Ttof(now.ru_utime)) - correction;
    cout << "Boxys card = " << totalcard << "  : ";
    cout << dt << " seconds\n";
    cout << ( ntimes / dt ) << " " << desc << "s/second\n";
    cout << ( ntimes*(totalcard) / dt ) << " points/second (ps1.card + ps2.card)\n";

    return 0;

}
@


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


1.2
log
@added int main & return 0
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: test010.c,v 1.1 1992/11/04 16:20:26 thoth Exp monica $";
d6 3
d18 1
a18 1
#include "dev-frags.h"
d24 3
a26 3
#include "generic-tests.h"
#include "point-utils.h"
#include "pointset-utils.h"
@


1.1
log
@Initial revision
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: test009.c,v 1.1 92/10/07 22:46:07 thoth Exp $";
d5 3
a7 1
// $Log:	test009.c,v $
d9 1
d17 3
a19 2
#include "IntPointSet.h"
#include "IPSIter.h"
d25 1
d33 2
a34 1
    unsigned choice, size, width, ntimes;
d42 1
a42 1
    IntPointSet (*f)(const IntPointSet&,const IntPointSet&);
d67 6
a72 6
    IntPoint	i1(make_random_point(size, 0, width-1));
    IntPoint	s1(make_random_point(size, 0, width-1));
    IntPointSet	ps1(i1,s1);
    IntPoint	i2(make_random_point(size, 0, width-1));
    IntPoint	s2(make_random_point(size, 0, width-1));
    IntPointSet	ps2(i2,s2);
d83 6
a88 6
	IntPoint	i1(make_random_point(size, 0, width-1));
	IntPoint	s1(make_random_point(size, 0, width-1));
	IntPointSet	ps1(i1,s1);
	IntPoint	i2(make_random_point(size, 0, width-1));
	IntPoint	s2(make_random_point(size, 0, width-1));
	IntPointSet	ps2(i2,s2);
d101 6
a106 6
	IntPoint	i1(make_random_point(size, 0, width-1));
	IntPoint	s1(make_random_point(size, 0, width-1));
	IntPointSet	ps1(i1,s1);
	IntPoint	i2(make_random_point(size, 0, width-1));
	IntPoint	s2(make_random_point(size, 0, width-1));
	IntPointSet	ps2(i2,s2);
d119 3
@
