libMicro: Remove from tree.

Upstream libMicro builds and runs on Haiku with minimal changes now
(no recipe as it does not have an INSTALL mechanism). I submitted
a pull request with those to upstream, but for now you can get them
from https://github.com/waddlesplash/libMicro.
This commit is contained in:
Augustin Cavalier 2017-05-12 17:05:38 -04:00
parent 7f06022487
commit c72855f6c0
113 changed files with 0 additions and 15861 deletions

View File

@ -19,5 +19,3 @@ SimpleTest execbenchTest :
SimpleTest forkbenchTest :
forkbench.c
;
SubInclude HAIKU_TOP src tests system benchmarks libMicro ;

View File

@ -1,3 +0,0 @@
Package: libMicro
Copyright: 2007 Sun Microsystems, Inc. All rights reserved.
License: OpenSolaris

View File

@ -1,358 +0,0 @@
SubDir HAIKU_TOP src tests system benchmarks libMicro ;
SEARCH_SOURCE = [ FDirName $(SUBDIR) ] ;
# filter warnings we don't want here
TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCH)
= [ FFilter $(TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCH))
: -Wall -Wmissing-prototypes -Wsign-compare ] ;
UseHeaders [ FDirName $(SUBDIR) $(SUBDIR) $(SUBDIR) $(SUBDIR) $(SUBDIR) headers posix ] : true ;
UseHeaders [ FDirName $(SUBDIR) ] : true ;
SubDirHdrs $(HAIKU_TOP) src tests system benchmarks libMicro ;
SubDirCcFlags -nostdinc ;
SubDirCcFlags -D_REENTRANT ;
SubDirCcFlags -include $(SUBDIR)/config_libmicro.h ;
StaticLibrary libmicro.a :
libmicro.c
libmicro_main.c
benchmark_init.c
benchmark_fini.c
benchmark_initrun.c
benchmark_finirun.c
benchmark_initbatch.c
benchmark_finibatch.c
benchmark_initworker.c
benchmark_finiworker.c
benchmark_optswitch.c
benchmark_result.c
;
StaticLibrary libelided.a :
elided.c ;
BinCommand <libmicro>bind :
bind.c
: libmicro.a $(TARGET_NETWORK_LIBS) ;
BinCommand atomic :
: libelided.a ;
BinCommand cachetocache :
: libelided.a ;
BinCommand cascade_mutex :
cascade_mutex.c
: libmicro.a ;
BinCommand cascade_cond :
cascade_cond.c
: libmicro.a ;
BinCommand cascade_lockf :
cascade_lockf.c
: libmicro.a ;
BinCommand cascade_fcntl :
cascade_fcntl.c
: libmicro.a ;
BinCommand cascade_flock :
cascade_flock.c
: libmicro.a ;
BinCommand chdir :
chdir.c
: libmicro.a ;
BinCommand close :
close.c
: libmicro.a ;
BinCommand close_tcp :
close_tcp.c
: libmicro.a $(TARGET_NETWORK_LIBS) ;
BinCommand connection :
connection.c
: libmicro.a $(TARGET_NETWORK_LIBS) ;
BinCommand dup :
dup.c
: libmicro.a ;
BinCommand exec_bin :
exec_bin.c
: libmicro.a ;
BinCommand exec :
exec.c
: libmicro.a ;
BinCommand exit :
exit.c
: libmicro.a ;
BinCommand exp :
exp.c
: libmicro.a ;
BinCommand fcntl :
fcntl.c
: libmicro.a ;
BinCommand fcntl_ndelay :
fcntl_ndelay.c
: libmicro.a $(TARGET_NETWORK_LIBS) ;
BinCommand file_lock :
file_lock.c
: libmicro.a ;
BinCommand fork :
fork.c
: libmicro.a ;
# atm unsupported
BinCommand getcontext :
: libelided.a ;
BinCommand getenv :
getenv.c
: libmicro.a ;
BinCommand gettimeofday :
gettimeofday.c
: libmicro.a ;
BinCommand <libmicro>getpeername :
getpeername.c
: libmicro.a $(TARGET_NETWORK_LIBS) ;
BinCommand getpid :
getpid.c
: libmicro.a ;
BinCommand getrusage :
getrusage.c
: libmicro.a ;
BinCommand getsockname :
getsockname.c
: libmicro.a $(TARGET_NETWORK_LIBS) ;
BinCommand isatty :
isatty.c
: libmicro.a ;
BinCommand listen :
listen.c
: libmicro.a $(TARGET_NETWORK_LIBS) ;
BinCommand localtime_r :
localtime_r.c
: libmicro.a ;
BinCommand <libmicro>log :
log.c
: libmicro.a ;
BinCommand longjmp :
longjmp.c
: libmicro.a ;
BinCommand lrand48 :
lrand48.c
: libmicro.a ;
BinCommand lseek :
lseek.c
: libmicro.a ;
BinCommand malloc :
malloc.c
: libmicro.a ;
BinCommand memcpy :
memcpy.c
: libmicro.a ;
BinCommand memmove :
memmove.c
: libmicro.a ;
BinCommand memrand :
memrand.c
: libmicro.a ;
BinCommand memset :
memset.c
: libmicro.a ;
BinCommand mktime :
mktime.c
: libmicro.a ;
# atm unsupported
BinCommand mprotect :
: libelided.a ;
BinCommand mmap :
mmap.c
: libmicro.a ;
# atm unsupported
BinCommand msync :
: libelided.a ;
BinCommand munmap :
munmap.c
: libmicro.a ;
BinCommand mutex :
mutex.c
: libmicro.a ;
BinCommand nop :
nop.c
: libmicro.a ;
BinCommand <libmicro>open :
open.c
: libmicro.a ;
BinCommand pipe :
pipe.c
: libmicro.a $(TARGET_NETWORK_LIBS) ;
BinCommand poll :
poll.c
: libmicro.a $(TARGET_NETWORK_LIBS) ;
BinCommand pread :
pread.c
: libmicro.a ;
BinCommand pthread_create :
pthread_create.c
: libmicro.a ;
BinCommand pwrite :
pwrite.c
: libmicro.a ;
BinCommand read :
read.c
: libmicro.a ;
BinCommand realpath :
realpath.c
: libmicro.a ;
BinCommand recurse :
recurse.c
recurse2.c
: libmicro.a ;
BinCommand select :
select.c
: libmicro.a $(TARGET_NETWORK_LIBS) ;
# atm unsupported
BinCommand semop :
: libelided.a ;
# atm unsupported
BinCommand setcontext :
: libelided.a ;
BinCommand setsockopt :
setsockopt.c
: libmicro.a $(TARGET_NETWORK_LIBS) ;
BinCommand sigaction :
sigaction.c
: libmicro.a ;
BinCommand siglongjmp :
siglongjmp.c
: libmicro.a ;
BinCommand signal :
signal.c
: libmicro.a ;
BinCommand sigprocmask :
sigprocmask.c
: libmicro.a ;
BinCommand <libmicro>socket :
socket.c
: libmicro.a $(TARGET_NETWORK_LIBS) ;
search on socket.c = [ FDirName $(SUBDIR) ] ;
BinCommand socketpair :
socketpair.c
: libmicro.a $(TARGET_NETWORK_LIBS) ;
BinCommand <libmicro>stat :
stat.c
: libmicro.a ;
BinCommand strcasecmp :
strcasecmp.c
: libmicro.a ;
BinCommand strchr :
strchr.c
: libmicro.a ;
BinCommand strcmp :
strcmp.c
: libmicro.a ;
BinCommand strcpy :
strcpy.c
: libmicro.a ;
BinCommand strftime :
strftime.c
: libmicro.a ;
BinCommand strlen :
strlen.c
: libmicro.a ;
BinCommand strtol :
strtol.c
: libmicro.a ;
BinCommand system :
system.c
: libmicro.a ;
BinCommand time :
time.c
: libmicro.a ;
BinCommand times :
times.c
: libmicro.a ;
BinCommand write :
write.c
: libmicro.a ;
BinCommand writev :
writev.c
: libmicro.a ;
BinCommand tattle :
tattle.c
: libmicro.a ;

View File

@ -1,95 +0,0 @@
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms
# of the Common Development and Distribution License
# (the "License"). You may not use this file except
# in compliance with the License.
#
# You can obtain a copy of the license at
# src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing
# permissions and limitations under the License.
#
# When distributing Covered Code, include this CDDL
# HEADER in each file and include the License file at
# usr/src/OPENSOLARIS.LICENSE. If applicable,
# add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your
# own identifying information: Portions Copyright [yyyy]
# [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
include Makefile.benchmarks
BINS= $(ALL:%=bin/%) bin/tattle
TARBALL_CONTENTS = \
Makefile.benchmarks \
Makefile.SunOS \
Makefile.Linux \
Makefile.Aix \
Makefile.com \
Makefile \
$(ALL:%=%.c) \
elided.c \
exec_bin.c \
libmicro.c \
libmicro_main.c \
libmicro.h \
recurse2.c \
benchmark_finibatch.c \
benchmark_initbatch.c \
benchmark_optswitch.c \
benchmark_fini.c \
benchmark_init.c \
benchmark_result.c \
benchmark_finirun.c \
benchmark_initrun.c \
benchmark_initworker.c \
benchmark_finiworker.c \
bench \
bench.sh \
mk_tarball \
multiview \
multiview.sh \
OPENSOLARIS.LICENSE \
tattle.c \
wrapper \
wrapper.sh \
README
default $(ALL) run cstyle lint tattle: $(BINS)
@cp bench.sh bench
@cp multiview.sh multiview
@cp wrapper.sh wrapper
@chmod +x bench multiview wrapper
@mkdir -p bin-`uname -m`; cd bin-`uname -m`; MACH=`uname -m` $(MAKE) -f ../Makefile.`uname -s` UNAME_RELEASE=`uname -r | sed 's/\./_/g'` $@
clean:
rm -rf bin bin-* wrapper multiview bench
bin:
@mkdir -p bin
$(BINS): bin
@cp wrapper.sh wrapper
@chmod +x wrapper
@ln -sf ../wrapper $@
libMicro.tar: FORCE
@chmod +x ./mk_tarball wrapper
@./mk_tarball $(TARBALL_CONTENTS)
FORCE:

View File

@ -1,41 +0,0 @@
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms
# of the Common Development and Distribution License
# (the "License"). You may not use this file except
# in compliance with the License.
#
# You can obtain a copy of the license at
# src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing
# permissions and limitations under the License.
#
# When distributing Covered Code, include this CDDL
# HEADER in each file and include the License file at
# usr/src/OPENSOLARIS.LICENSE. If applicable,
# add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your
# own identifying information: Portions Copyright [yyyy]
# [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
CFLAGS= -O3
CPPFLAGS = -D_REENTRANT
include ../Makefile.com
NSLLIB= -lnsl
SOCKLIB=
.KEEP_STATE:

View File

@ -1,43 +0,0 @@
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms
# of the Common Development and Distribution License
# (the "License"). You may not use this file except
# in compliance with the License.
#
# You can obtain a copy of the license at
# src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing
# permissions and limitations under the License.
#
# When distributing Covered Code, include this CDDL
# HEADER in each file and include the License file at
# usr/src/OPENSOLARIS.LICENSE. If applicable,
# add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your
# own identifying information: Portions Copyright [yyyy]
# [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
CC= gcc
#CFLAGS= -O -DUSE_SEMOP
CPPFLAGS= -DUSE_SEMOP -D_REENTRANT
MATHLIB= -lm
ELIDED_BENCHMARKS= \
cachetocache \
atomic
include ../Makefile.com

View File

@ -1,61 +0,0 @@
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms
# of the Common Development and Distribution License
# (the "License"). You may not use this file except
# in compliance with the License.
#
# You can obtain a copy of the license at
# src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing
# permissions and limitations under the License.
#
# When distributing Covered Code, include this CDDL
# HEADER in each file and include the License file at
# usr/src/OPENSOLARIS.LICENSE. If applicable,
# add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your
# own identifying information: Portions Copyright [yyyy]
# [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
CPPFLAGS= -DUSE_GETHRTIME -D_REENTRANT
CFLAGS = -O $(extra_CFLAGS)
#
# These defines allow libmicro to be compiled against older Solaris
# releases by turning off the tests which don't work there.
#
# This is a little contorted-- UNAME_RELEASE is set as an environment
# variable for us by the invoking make process (see Makefile)-- it is
# the output of uname -r | sed 's/\./_/g'.
#
# We couldn't find any other gmake/unix make portable way to make this
# work.
#
ELIDED_BENCHMARKS_5_8=atomic cachetocache
ELIDED_BENCHMARKS_5_9=atomic
ELIDED_BENCHMARKS_CMN=cascade_flock
ELIDED_BENCHMARKS=$(ELIDED_BENCHMARKS_CMN) $(ELIDED_BENCHMARKS_$(UNAME_RELEASE))
include ../Makefile.com
NSLLIB= -lnsl
SOCKLIB= -lsocket
UCBLIB= -lc -L/usr/ucblib -lucb -R/usr/ucblib
MATHLIB= -lm
.KEEP_STATE:

View File

@ -1,112 +0,0 @@
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms
# of the Common Development and Distribution License
# (the "License"). You may not use this file except
# in compliance with the License.
#
# You can obtain a copy of the license at
# src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing
# permissions and limitations under the License.
#
# When distributing Covered Code, include this CDDL
# HEADER in each file and include the License file at
# usr/src/OPENSOLARIS.LICENSE. If applicable,
# add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your
# own identifying information: Portions Copyright [yyyy]
# [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
ALL= \
atomic \
bind \
cachetocache \
cascade_mutex \
cascade_cond \
cascade_lockf \
cascade_fcntl \
cascade_flock \
chdir \
close \
close_tcp \
connection \
dup \
exec \
exit \
exp \
fcntl \
fcntl_ndelay \
file_lock \
fork \
getcontext \
getenv \
gettimeofday \
getpeername \
getpid \
getrusage \
getsockname \
isatty \
listen \
localtime_r \
log \
longjmp \
lrand48 \
lseek \
malloc \
memcpy \
memmove \
memrand \
memset \
mktime \
mprotect \
mmap \
msync \
munmap \
mutex \
nop \
open \
pipe \
poll \
pread \
pthread_create \
pwrite \
read \
realpath \
recurse \
select \
semop \
setcontext \
setsockopt \
sigaction \
siglongjmp \
signal \
sigprocmask \
socket \
socketpair \
stat \
strcasecmp \
strchr \
strcmp \
strcpy \
strftime \
strlen \
strtol \
system \
time \
times \
write \
writev

View File

@ -1,127 +0,0 @@
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms
# of the Common Development and Distribution License
# (the "License"). You may not use this file except
# in compliance with the License.
#
# You can obtain a copy of the license at
# src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing
# permissions and limitations under the License.
#
# When distributing Covered Code, include this CDDL
# HEADER in each file and include the License file at
# usr/src/OPENSOLARIS.LICENSE. If applicable,
# add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your
# own identifying information: Portions Copyright [yyyy]
# [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
include ../Makefile.benchmarks
EXTRA_CFILES= \
exec_bin.c \
elided.c \
tattle.c
#
# some definitions to make getting compiler versions possible - avoid quotes
#
COMPILER_VERSION_CMD_cc=cc -V 2>&1 | egrep Sun
COMPILER_VERSION_CMD_gcc=gcc -dumpversion
COMPILER_VERSION_CMD=$(COMPILER_VERSION_CMD_$(CC))
default: $(ALL) tattle
cstyle:
for file in $(ALL:%=../%.c) $(EXTRA_CFILES:%=../%) ; \
do cstyle -p $$file ;\
done
lint: libmicro.ln $(ALL:%=%.lint) $(EXTRA_CFILES:%.c=%.lint)
$(EXTRA_CFILES:%.c=%.lint):
$(LINT) ../$(@:%.lint=%.c) -I. -mu -lc libmicro.ln -lm
%.lint: ../%.c libmicro.ln
$(LINT) -mu $(CPPFLAGS) $< libmicro.ln -lpthread -lsocket -lnsl -lm
%.o: ../%.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
libmicro.ln: ../libmicro.c ../libmicro_main.c ../libmicro.h ../benchmark_*.c
$(LINT) -muc $(CPPFLAGS) ../libmicro.c ../libmicro_main.c ../benchmark_*.c
CPPFLAGS+= -D_REENTRANT
bind_EXTRA_LIBS=$(NSLLIB) $(SOCKLIB)
cascade_flock_EXTRA_LIBS=$(UCBLIB)
close_tcp_EXTRA_LIBS=$(NSLLIB) $(SOCKLIB)
connection_EXTRA_LIBS=$(NSLLIB) $(SOCKLIB)
fcntl_ndelay_EXTRA_LIBS=$(SOCKLIB)
getpeername_EXTRA_LIBS=$(NSLLIB) $(SOCKLIB)
getsockname_EXTRA_LIBS=$(NSLLIB) $(SOCKLIB)
listen_EXTRA_LIBS=$(NSLLIB) $(SOCKLIB)
log_EXTRA_LIBS=$(MATHLIB)
pipe_EXTRA_LIBS=$(NSLLIB) $(SOCKLIB)
poll_EXTRA_LIBS=$(SOCKLIB)
select_EXTRA_LIBS=$(SOCKLIB)
setsockopt_EXTRA_LIBS=$(NSLLIB) $(SOCKLIB)
socket_EXTRA_LIBS=$(SOCKLIB)
socketpair_EXTRA_LIBS=$(SOCKLIB)
BENCHMARK_FUNCS= \
benchmark_init.o \
benchmark_fini.o \
benchmark_initrun.o \
benchmark_finirun.o \
benchmark_initbatch.o \
benchmark_finibatch.o \
benchmark_initworker.o \
benchmark_finiworker.o \
benchmark_optswitch.o \
benchmark_result.o
recurse_EXTRA_DEPS=recurse2.o
recurse: $(recurse_EXTRA_DEPS)
libmicro.a: libmicro.o libmicro_main.o $(BENCHMARK_FUNCS)
$(AR) -cr libmicro.a libmicro.o libmicro_main.o $(BENCHMARK_FUNCS)
tattle: ../tattle.c libmicro.a
echo "char * compiler_version = \""`$(COMPILER_VERSION_CMD)`"\";" > tattle.h
echo "char * CC = \""$(CC)"\";" >> tattle.h
echo "char * extra_compiler_flags = \""$(extra_CFLAGS)"\";" >> tattle.h
$(CC) -o tattle $(CFLAGS) -I. ../tattle.c libmicro.a -lrt -lm
$(ELIDED_BENCHMARKS): ../elided.c
$(CC) -o $(@) ../elided.c
%: libmicro.a %.o
$(CC) -o $(@) $(@).o $($(@)_EXTRA_DEPS) $(CFLAGS) libmicro.a $($(@)_EXTRA_LIBS) $(EXTRA_LIBS) -lpthread -lm
exec: exec_bin
exec_bin: exec_bin.o
$(CC) -o exec_bin $(CFLAGS) exec_bin.o
FORCE:
._KEEP_STATE:

View File

@ -1,385 +0,0 @@
Unless otherwise noted, all files in this distribution are released
under the Common Development and Distribution License (CDDL),
Version 1.0 only. Exceptions are noted within the associated
source files.
--------------------------------------------------------------------
COMMON DEVELOPMENT AND DISTRIBUTION LICENSE Version 1.0
1. Definitions.
1.1. "Contributor" means each individual or entity that creates
or contributes to the creation of Modifications.
1.2. "Contributor Version" means the combination of the Original
Software, prior Modifications used by a Contributor (if any),
and the Modifications made by that particular Contributor.
1.3. "Covered Software" means (a) the Original Software, or (b)
Modifications, or (c) the combination of files containing
Original Software with files containing Modifications, in
each case including portions thereof.
1.4. "Executable" means the Covered Software in any form other
than Source Code.
1.5. "Initial Developer" means the individual or entity that first
makes Original Software available under this License.
1.6. "Larger Work" means a work which combines Covered Software or
portions thereof with code not governed by the terms of this
License.
1.7. "License" means this document.
1.8. "Licensable" means having the right to grant, to the maximum
extent possible, whether at the time of the initial grant or
subsequently acquired, any and all of the rights conveyed
herein.
1.9. "Modifications" means the Source Code and Executable form of
any of the following:
A. Any file that results from an addition to, deletion from or
modification of the contents of a file containing Original
Software or previous Modifications;
B. Any new file that contains any part of the Original
Software or previous Modifications; or
C. Any new file that is contributed or otherwise made
available under the terms of this License.
1.10. "Original Software" means the Source Code and Executable
form of computer software code that is originally released
under this License.
1.11. "Patent Claims" means any patent claim(s), now owned or
hereafter acquired, including without limitation, method,
process, and apparatus claims, in any patent Licensable by
grantor.
1.12. "Source Code" means (a) the common form of computer software
code in which modifications are made and (b) associated
documentation included in or with such code.
1.13. "You" (or "Your") means an individual or a legal entity
exercising rights under, and complying with all of the terms
of, this License. For legal entities, "You" includes any
entity which controls, is controlled by, or is under common
control with You. For purposes of this definition,
"control" means (a) the power, direct or indirect, to cause
the direction or management of such entity, whether by
contract or otherwise, or (b) ownership of more than fifty
percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants.
2.1. The Initial Developer Grant.
Conditioned upon Your compliance with Section 3.1 below and
subject to third party intellectual property claims, the Initial
Developer hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or
trademark) Licensable by Initial Developer, to use,
reproduce, modify, display, perform, sublicense and
distribute the Original Software (or portions thereof),
with or without Modifications, and/or as part of a Larger
Work; and
(b) under Patent Claims infringed by the making, using or
selling of Original Software, to make, have made, use,
practice, sell, and offer for sale, and/or otherwise
dispose of the Original Software (or portions thereof).
(c) The licenses granted in Sections 2.1(a) and (b) are
effective on the date Initial Developer first distributes
or otherwise makes the Original Software available to a
third party under the terms of this License.
(d) Notwithstanding Section 2.1(b) above, no patent license is
granted: (1) for code that You delete from the Original
Software, or (2) for infringements caused by: (i) the
modification of the Original Software, or (ii) the
combination of the Original Software with other software
or devices.
2.2. Contributor Grant.
Conditioned upon Your compliance with Section 3.1 below and
subject to third party intellectual property claims, each
Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or
trademark) Licensable by Contributor to use, reproduce,
modify, display, perform, sublicense and distribute the
Modifications created by such Contributor (or portions
thereof), either on an unmodified basis, with other
Modifications, as Covered Software and/or as part of a
Larger Work; and
(b) under Patent Claims infringed by the making, using, or
selling of Modifications made by that Contributor either
alone and/or in combination with its Contributor Version
(or portions of such combination), to make, use, sell,
offer for sale, have made, and/or otherwise dispose of:
(1) Modifications made by that Contributor (or portions
thereof); and (2) the combination of Modifications made by
that Contributor with its Contributor Version (or portions
of such combination).
(c) The licenses granted in Sections 2.2(a) and 2.2(b) are
effective on the date Contributor first distributes or
otherwise makes the Modifications available to a third
party.
(d) Notwithstanding Section 2.2(b) above, no patent license is
granted: (1) for any code that Contributor has deleted
from the Contributor Version; (2) for infringements caused
by: (i) third party modifications of Contributor Version,
or (ii) the combination of Modifications made by that
Contributor with other software (except as part of the
Contributor Version) or other devices; or (3) under Patent
Claims infringed by Covered Software in the absence of
Modifications made by that Contributor.
3. Distribution Obligations.
3.1. Availability of Source Code.
Any Covered Software that You distribute or otherwise make
available in Executable form must also be made available in Source
Code form and that Source Code form must be distributed only under
the terms of this License. You must include a copy of this
License with every copy of the Source Code form of the Covered
Software You distribute or otherwise make available. You must
inform recipients of any such Covered Software in Executable form
as to how they can obtain such Covered Software in Source Code
form in a reasonable manner on or through a medium customarily
used for software exchange.
3.2. Modifications.
The Modifications that You create or to which You contribute are
governed by the terms of this License. You represent that You
believe Your Modifications are Your original creation(s) and/or
You have sufficient rights to grant the rights conveyed by this
License.
3.3. Required Notices.
You must include a notice in each of Your Modifications that
identifies You as the Contributor of the Modification. You may
not remove or alter any copyright, patent or trademark notices
contained within the Covered Software, or any notices of licensing
or any descriptive text giving attribution to any Contributor or
the Initial Developer.
3.4. Application of Additional Terms.
You may not offer or impose any terms on any Covered Software in
Source Code form that alters or restricts the applicable version
of this License or the recipients' rights hereunder. You may
choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of
Covered Software. However, you may do so only on Your own behalf,
and not on behalf of the Initial Developer or any Contributor.
You must make it absolutely clear that any such warranty, support,
indemnity or liability obligation is offered by You alone, and You
hereby agree to indemnify the Initial Developer and every
Contributor for any liability incurred by the Initial Developer or
such Contributor as a result of warranty, support, indemnity or
liability terms You offer.
3.5. Distribution of Executable Versions.
You may distribute the Executable form of the Covered Software
under the terms of this License or under the terms of a license of
Your choice, which may contain terms different from this License,
provided that You are in compliance with the terms of this License
and that the license for the Executable form does not attempt to
limit or alter the recipient's rights in the Source Code form from
the rights set forth in this License. If You distribute the
Covered Software in Executable form under a different license, You
must make it absolutely clear that any terms which differ from
this License are offered by You alone, not by the Initial
Developer or Contributor. You hereby agree to indemnify the
Initial Developer and every Contributor for any liability incurred
by the Initial Developer or such Contributor as a result of any
such terms You offer.
3.6. Larger Works.
You may create a Larger Work by combining Covered Software with
other code not governed by the terms of this License and
distribute the Larger Work as a single product. In such a case,
You must make sure the requirements of this License are fulfilled
for the Covered Software.
4. Versions of the License.
4.1. New Versions.
Sun Microsystems, Inc. is the initial license steward and may
publish revised and/or new versions of this License from time to
time. Each version will be given a distinguishing version number.
Except as provided in Section 4.3, no one other than the license
steward has the right to modify this License.
4.2. Effect of New Versions.
You may always continue to use, distribute or otherwise make the
Covered Software available under the terms of the version of the
License under which You originally received the Covered Software.
If the Initial Developer includes a notice in the Original
Software prohibiting it from being distributed or otherwise made
available under any subsequent version of the License, You must
distribute and make the Covered Software available under the terms
of the version of the License under which You originally received
the Covered Software. Otherwise, You may also choose to use,
distribute or otherwise make the Covered Software available under
the terms of any subsequent version of the License published by
the license steward.
4.3. Modified Versions.
When You are an Initial Developer and You want to create a new
license for Your Original Software, You may create and use a
modified version of this License if You: (a) rename the license
and remove any references to the name of the license steward
(except to note that the license differs from this License); and
(b) otherwise make it clear that the license contains terms which
differ from this License.
5. DISCLAIMER OF WARRANTY.
COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS"
BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED
SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR
PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY
COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE
INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY
NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF
WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS
DISCLAIMER.
6. TERMINATION.
6.1. This License and the rights granted hereunder will terminate
automatically if You fail to comply with terms herein and fail to
cure such breach within 30 days of becoming aware of the breach.
Provisions which, by their nature, must remain in effect beyond
the termination of this License shall survive.
6.2. If You assert a patent infringement claim (excluding
declaratory judgment actions) against Initial Developer or a
Contributor (the Initial Developer or Contributor against whom You
assert such claim is referred to as "Participant") alleging that
the Participant Software (meaning the Contributor Version where
the Participant is a Contributor or the Original Software where
the Participant is the Initial Developer) directly or indirectly
infringes any patent, then any and all rights granted directly or
indirectly to You by such Participant, the Initial Developer (if
the Initial Developer is not the Participant) and all Contributors
under Sections 2.1 and/or 2.2 of this License shall, upon 60 days
notice from Participant terminate prospectively and automatically
at the expiration of such 60 day notice period, unless if within
such 60 day period You withdraw Your claim with respect to the
Participant Software against such Participant either unilaterally
or pursuant to a written agreement with Participant.
6.3. In the event of termination under Sections 6.1 or 6.2 above,
all end user licenses that have been validly granted by You or any
distributor hereunder prior to termination (excluding licenses
granted to You by any distributor) shall survive termination.
7. LIMITATION OF LIABILITY.
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE
INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF
COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE
LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR
CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT
LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK
STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL
INJURY RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT
APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO
NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR
CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT
APPLY TO YOU.
8. U.S. GOVERNMENT END USERS.
The Covered Software is a "commercial item," as that term is
defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial
computer software" (as that term is defined at 48
C.F.R. 252.227-7014(a)(1)) and "commercial computer software
documentation" as such terms are used in 48 C.F.R. 12.212
(Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48
C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all
U.S. Government End Users acquire Covered Software with only those
rights set forth herein. This U.S. Government Rights clause is in
lieu of, and supersedes, any other FAR, DFAR, or other clause or
provision that addresses Government rights in computer software
under this License.
9. MISCELLANEOUS.
This License represents the complete agreement concerning subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. This License shall be governed
by the law of the jurisdiction specified in a notice contained
within the Original Software (except to the extent applicable law,
if any, provides otherwise), excluding such jurisdiction's
conflict-of-law provisions. Any litigation relating to this
License shall be subject to the jurisdiction of the courts located
in the jurisdiction and venue specified in a notice contained
within the Original Software, with the losing party responsible
for costs, including, without limitation, court costs and
reasonable attorneys' fees and expenses. The application of the
United Nations Convention on Contracts for the International Sale
of Goods is expressly excluded. Any law or regulation which
provides that the language of a contract shall be construed
against the drafter shall not apply to this License. You agree
that You alone are responsible for compliance with the United
States export administration regulations (and the export control
laws and regulation of any other countries) when You use,
distribute or otherwise make available any Covered Software.
10. RESPONSIBILITY FOR CLAIMS.
As between Initial Developer and the Contributors, each party is
responsible for claims and damages arising, directly or
indirectly, out of its utilization of rights under this License
and You agree to work with Initial Developer and Contributors to
distribute such responsibility on an equitable basis. Nothing
herein is intended or shall be deemed to constitute any admission
of liability.
--------------------------------------------------------------------
NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND
DISTRIBUTION LICENSE (CDDL)
For Covered Software in this distribution, this License shall
be governed by the laws of the State of California (excluding
conflict-of-law provisions).
Any litigation relating to this License shall be subject to the
jurisdiction of the Federal Courts of the Northern District of
California and the state courts of the State of California, with
venue lying in Santa Clara County, California.

View File

@ -1,85 +0,0 @@
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms
# of the Common Development and Distribution License
# (the "License"). You may not use this file except
# in compliance with the License.
#
# You can obtain a copy of the license at
# src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing
# permissions and limitations under the License.
#
# When distributing Covered Code, include this CDDL
# HEADER in each file and include the License file at
# usr/src/OPENSOLARIS.LICENSE. If applicable,
# add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your
# own identifying information: Portions Copyright [yyyy]
# [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
Building the tarball
--------------------
As long as cc is in your path, (gcc on Linux),
% tar xf libMicro.tar
% make
will build the benchmark suite.
Running the benchmarks
-----------------------
A set of generic scripts to invoke each micro benchmark
are created in the bin directory; these may be invoked
directly. Note that the actual binaries are created in
OS-specific directories; this allows one to build for
all varients (x86/sparc/Solaris/Linux) in one place.
To collect a complete set of benchmarks, use the bench
script and redirect its output to a file.
% ./bench > output
To compare the output of two or more runs, use multiview in the src
directory:
% ./multiview reference compare1 compare2 compare2 > compare.html
%
where the reference and compare files contain the output of different
libmicro runs.
The compare.html file will allow quick comparisons to be drawn,
allowing a variety of experiments to be quickly analyzed.
All benchmarks support the following options:
[-1] (single process; overrides -P > 1)
[-A] (align with clock)
[-B batch-size (default 10)]
[-C minimum number of samples (default 0)]
[-D duration in msecs (default 10s)]
[-E (echo name to stderr)]
[-H] (suppress headers)
[-I] specify approx. time per op in nsecs
[-L] (print argument line)
[-M] (reports mean rather than median)
[-N test-name ]
[-P processes (default 1)]
[-S] (print detailed stats)
[-T threads (default 1)]
[-V] (print the libMicro version and exit)
[-W] (flag possible benchmark problems)

View File

@ -1,74 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* benchmarks atomic add on Solaris - useful for platform comparisons.
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <atomic.h>
#include "libmicro.h"
int
benchmark_init()
{
(void) sprintf(lm_usage, "note: measures atomic_add_32_nv()");
lm_tsdsize = 0;
return (0);
}
static unsigned int value = 0;
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
unsigned int i;
for (i = 0; i < lm_optB; i += 10) {
(void) atomic_add_32_nv(&value, 1);
(void) atomic_add_32_nv(&value, 1);
(void) atomic_add_32_nv(&value, 1);
(void) atomic_add_32_nv(&value, 1);
(void) atomic_add_32_nv(&value, 1);
(void) atomic_add_32_nv(&value, 1);
(void) atomic_add_32_nv(&value, 1);
(void) atomic_add_32_nv(&value, 1);
(void) atomic_add_32_nv(&value, 1);
(void) atomic_add_32_nv(&value, 1);
}
res->re_count = i;
return (0);
}

View File

@ -1,484 +0,0 @@
#!/bin/sh
#
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms
# of the Common Development and Distribution License
# (the "License"). You may not use this file except
# in compliance with the License.
#
# You can obtain a copy of the license at
# src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing
# permissions and limitations under the License.
#
# When distributing Covered Code, include this CDDL
# HEADER in each file and include the License file at
# usr/src/OPENSOLARIS.LICENSE. If applicable,
# add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your
# own identifying information: Portions Copyright [yyyy]
# [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
bench_version=0.4.0
libmicro_version=`bin/tattle -V`
case $libmicro_version in
$bench_version)
;;
*)
echo "ERROR: libMicro version doesn't match 'bench' script version"
exit 1
esac
TMPROOT=/tmp/libmicro.$$
VARROOT=/var/tmp/libmicro.$$
mkdir -p $TMPROOT
mkdir -p $VARROOT
trap "rm -rf $TMPROOT $VARROOT" 0 2
TFILE=$TMPROOT/data
IFILE=$TMPROOT/ifile
TDIR1=$TMPROOT/0/1/2/3/4/5/6/7/8/9
TDIR2=$TMPROOT/1/2/3/4/5/6/7/8/9/0
VFILE=$VARROOT/data
VDIR1=$VARROOT/0/1/2/3/4/5/6/7/8/9
VDIR2=$VARROOT/1/2/3/4/5/6/7/8/9/0
#OPTS="-E -C 200 -L -S -W"
echo "FIXME: adding -1 to the original opts, (possible pthread issue?)"
OPTS="-1 -E -C 200 -L -S -W"
dd if=/dev/zero of=$TFILE bs=1024k count=10 2>/dev/null
dd if=/dev/zero of=$VFILE bs=1024k count=10 2>/dev/null
mkdir -p $TDIR1 $TDIR2
mkdir -p $VDIR1 $VDIR2
touch $IFILE
ARCH=`uname -m`
# produce benchmark header for easier comparisons
hostname=`uname -n`
if [ -f /usr/sbin/psrinfo ]; then
p_count=`psrinfo|wc -l`
p_mhz=`psrinfo -v | awk '/operates/{print $6 "MHz"; exit }'`
p_type=`psrinfo -vp 2>/dev/null | awk '{if (NR == 3) {print $0; exit}}'`
fi
if [ -f /proc/cpuinfo ]; then
p_count=`egrep processor /proc/cpuinfo | wc -l`
p_mhz=`awk -F: '/cpu MHz/{printf("%5.0f00Mhz\n",$2/100); exit}' /proc/cpuinfo`
p_type=`awk -F: '/model name/{print $2; exit}' /proc/cpuinfo`
fi
printf "!Libmicro_#: %30s\n" $libmicro_version
printf "!Options: %30s\n" "$OPTS"
printf "!Machine_name: %30s\n" $hostname
printf "!OS_name: %30s\n" `uname -s`
printf "!OS_release: %30s\n" `uname -r`
printf "!OS_build: %30.18s\n" "`uname -v`"
printf "!Processor: %30s\n" `uname -m`
printf "!#CPUs: %30s\n" $p_count
printf "!CPU_MHz: %30s\n" $p_mhz
printf "!CPU_NAME: %30s\n" "$p_type"
printf "!IP_address: %30s\n" `getent hosts $hostname | awk '{print $1}'`
printf "!Run_by: %30s\n" $LOGNAME
printf "!Date: %30s\n" "`date '+%D %R'`"
printf "!Compiler: %30s\n" `bin/tattle -c`
printf "!Compiler Ver.:%30s\n" "`bin/tattle -v`"
printf "!sizeof(long): %30s\n" `bin/tattle -s`
printf "!extra_CFLAGS: %30s\n" "`bin/tattle -f`"
printf "!TimerRes: %30s\n" "`bin/tattle -r`"
mkdir -p $TMPROOT/bin
cp bin-$ARCH/exec_bin $TMPROOT/bin/$A
while read A B
do
# $A contains the command, $B contains the arguments
# we echo blank lines and comments
# we ship anything which fails to match *$1* (useful
# if we only want to test one case, but a nasty hack)
case $A in
""|"#"*)
echo "$A $B"
continue
;;
*$1*)
;;
*)
continue
esac
if [ ! -f $TMPROOT/bin/$A ]
then
cp bin-$ARCH/$A $TMPROOT/bin/$A
fi
(cd $TMPROOT && eval "bin/$A $B")
done <<.
#
# Obligatory null system call: use very short time
# for default since SuSe implements this "syscall" in userland
#
getpid $OPTS -N "getpid" -I 5
getenv $OPTS -N "getenv" -s 100 -I 100
getenv $OPTS -N "getenvT2" -s 100 -I 100 -T 2
gettimeofday $OPTS -N "gettimeofday"
log $OPTS -N "log" -I 20
exp $OPTS -N "exp" -I 20
lrand48 $OPTS -N "lrand48"
memset $OPTS -N "memset_10" -s 10 -I 10
memset $OPTS -N "memset_256" -s 256 -I 20
memset $OPTS -N "memset_256_u" -s 256 -a 1 -I 20
memset $OPTS -N "memset_1k" -s 1k -I 100
memset $OPTS -N "memset_4k" -s 4k -I 250
memset $OPTS -N "memset_4k_uc" -s 4k -u -I 400
memset $OPTS -N "memset_10k" -s 10k -I 600
memset $OPTS -N "memset_1m" -s 1m -I 200000
memset $OPTS -N "memset_10m" -s 10m -I 2000000
memset $OPTS -N "memsetP2_10m" -s 10m -P 2 -I 2000000
memrand $OPTS -N "memrand" -s 128m -B 10000
cachetocache $OPTS -N "cachetocache" -s 100k -T 2 -I 200
isatty $OPTS -N "isatty_yes"
isatty $OPTS -N "isatty_no" -f $IFILE
malloc $OPTS -N "malloc_10" -s 10 -g 10 -I 50
malloc $OPTS -N "malloc_100" -s 100 -g 10 -I 50
malloc $OPTS -N "malloc_1k" -s 1k -g 10 -I 50
malloc $OPTS -N "malloc_10k" -s 10k -g 10 -I 50
malloc $OPTS -N "malloc_100k" -s 100k -g 10 -I 2000
malloc $OPTS -N "mallocT2_10" -s 10 -g 10 -T 2 -I 200
malloc $OPTS -N "mallocT2_100" -s 100 -g 10 -T 2 -I 200
malloc $OPTS -N "mallocT2_1k" -s 1k -g 10 -T 2 -I 200
malloc $OPTS -N "mallocT2_10k" -s 10k -g 10 -T 2 -I 200
malloc $OPTS -N "mallocT2_100k" -s 100k -g 10 -T 2 -I 10000
close $OPTS -N "close_bad" -B 32 -b
close $OPTS -N "close_tmp" -B 32 -f $TFILE
close $OPTS -N "close_usr" -B 32 -f $VFILE
close $OPTS -N "close_zero" -B 32 -f /dev/zero
memcpy $OPTS -N "memcpy_10" -s 10 -I 10
memcpy $OPTS -N "memcpy_1k" -s 1k -I 50
memcpy $OPTS -N "memcpy_10k" -s 10k -I 800
memcpy $OPTS -N "memcpy_1m" -s 1m -I 500000
memcpy $OPTS -N "memcpy_10m" -s 10m -I 5000000
strcpy $OPTS -N "strcpy_10" -s 10 -I 5
strcpy $OPTS -N "strcpy_1k" -s 1k -I 100
strlen $OPTS -N "strlen_10" -s 10 -I 5
strlen $OPTS -N "strlen_1k" -s 1k -I 100
strchr $OPTS -N "strchr_10" -s 10 -I 5
strchr $OPTS -N "strchr_1k" -s 1k -I 200
strcmp $OPTS -N "strcmp_10" -s 10 -I 10
strcmp $OPTS -N "strcmp_1k" -s 1k -I 200
strcasecmp $OPTS -N "scasecmp_10" -s 10 -I 50
strcasecmp $OPTS -N "scasecmp_1k" -s 1k -I 20000
strtol $OPTS -N "strtol" -I 20
getcontext $OPTS -N "getcontext" -I 100
setcontext $OPTS -N "setcontext" -I 100
mutex $OPTS -N "mutex_st" -I 10
mutex $OPTS -N "mutex_mt" -t -I 10
mutex $OPTS -N "mutex_T2" -T 2 -I 100
longjmp $OPTS -N "longjmp" -I 10
siglongjmp $OPTS -N "siglongjmp" -I 20
getrusage $OPTS -N "getrusage" -I 200
times $OPTS -N "times" -I 200
time $OPTS -N "time" -I 50
localtime_r $OPTS -N "localtime_r" -I 200
strftime $OPTS -N "strftime" -I 10000
mktime $OPTS -N "mktime" -I 500
mktime $OPTS -N "mktimeT2" -T 2 -I 1000
cascade_mutex $OPTS -N "c_mutex_1" -I 50
cascade_mutex $OPTS -N "c_mutex_10" -T 10 -I 5000
cascade_mutex $OPTS -N "c_mutex_200" -T 200 -I 2000000
cascade_cond $OPTS -N "c_cond_1" -I 100
cascade_cond $OPTS -N "c_cond_10" -T 10 -I 3000
cascade_cond $OPTS -N "c_cond_200" -T 200 -I 2000000
cascade_lockf $OPTS -N "c_lockf_1" -I 1000
cascade_lockf $OPTS -N "c_lockf_10" -P 10 -I 50000
cascade_lockf $OPTS -N "c_lockf_200" -P 200 -I 5000000
cascade_flock $OPTS -N "c_flock" -I 1000
cascade_flock $OPTS -N "c_flock_10" -P 10 -I 50000
cascade_flock $OPTS -N "c_flock_200" -P 200 -I 5000000
cascade_fcntl $OPTS -N "c_fcntl_1" -I 2000
cascade_fcntl $OPTS -N "c_fcntl_10" -P 10 -I 20000
cascade_fcntl $OPTS -N "c_fcntl_200" -P 200 -I 5000000
file_lock $OPTS -N "file_lock" -I 1000
getsockname $OPTS -N "getsockname" -I 100
getpeername $OPTS -N "getpeername" -I 100
chdir $OPTS -N "chdir_tmp" -I 2000 $TDIR1 $TDIR2
chdir $OPTS -N "chdir_usr" -I 2000 $VDIR1 $VDIR2
chdir $OPTS -N "chgetwd_tmp" -I 3000 -g $TDIR1 $TDIR2
chdir $OPTS -N "chgetwd_usr" -I 3000 -g $VDIR1 $VDIR2
realpath $OPTS -N "realpath_tmp" -I 3000 -f $TDIR1
realpath $OPTS -N "realpath_usr" -I 3000 -f $VDIR1
stat $OPTS -N "stat_tmp" -I 1000 -f $TFILE
stat $OPTS -N "stat_usr" -I 1000 -f $VFILE
fcntl $OPTS -N "fcntl_tmp" -I 100 -f $TFILE
fcntl $OPTS -N "fcntl_usr" -I 100 -f $VFILE
fcntl_ndelay $OPTS -N "fcntl_ndelay" -I 100
lseek $OPTS -N "lseek_t8k" -s 8k -I 50 -f $TFILE
lseek $OPTS -N "lseek_u8k" -s 8k -I 50 -f $VFILE
open $OPTS -N "open_tmp" -B 256 -f $TFILE
open $OPTS -N "open_usr" -B 256 -f $VFILE
open $OPTS -N "open_zero" -B 256 -f /dev/zero
dup $OPTS -N "dup" -B 512
socket $OPTS -N "socket_u" -B 256
socket $OPTS -N "socket_i" -B 256 -f PF_INET
socketpair $OPTS -N "socketpair" -B 256
setsockopt $OPTS -N "setsockopt" -I 200
bind $OPTS -N "bind" -B 100
listen $OPTS -N "listen" -B 100
connection $OPTS -N "connection" -B 256
poll $OPTS -N "poll_10" -n 10 -I 500
poll $OPTS -N "poll_100" -n 100 -I 1000
poll $OPTS -N "poll_1000" -n 1000 -I 5000
poll $OPTS -N "poll_w10" -n 10 -I 500 -w 1
poll $OPTS -N "poll_w100" -n 100 -I 2000 -w 10
poll $OPTS -N "poll_w1000" -n 1000 -I 40000 -w 100
select $OPTS -N "select_10" -n 10 -I 500
select $OPTS -N "select_100" -n 100 -I 1000
select $OPTS -N "select_1000" -n 1000 -I 5000
select $OPTS -N "select_w10" -n 10 -I 500 -w 1
select $OPTS -N "select_w100" -n 100 -I 2000 -w 10
select $OPTS -N "select_w1000" -n 1000 -I 40000 -w 100
semop $OPTS -N "semop" -I 200
sigaction $OPTS -N "sigaction" -I 100
signal $OPTS -N "signal" -I 1000
sigprocmask $OPTS -N "sigprocmask" -I 200
pthread_create $OPTS -N "pthread_8" -B 8
pthread_create $OPTS -N "pthread_32" -B 32
pthread_create $OPTS -N "pthread_128" -B 128
pthread_create $OPTS -N "pthread_512" -B 512
fork $OPTS -N "fork_10" -B 10
fork $OPTS -N "fork_100" -B 100 -C 100
fork $OPTS -N "fork_1000" -B 1000 -C 50
exit $OPTS -N "exit_10" -B 10
exit $OPTS -N "exit_100" -B 100
exit $OPTS -N "exit_1000" -B 1000 -C 50
exit $OPTS -N "exit_10_nolibc" -e -B 10
exec $OPTS -N "exec" -B 10
system $OPTS -N "system" -I 1000000
recurse $OPTS -N "recurse" -B 512
read $OPTS -N "read_t1k" -s 1k -f $TFILE
read $OPTS -N "read_t10k" -s 10k -f $TFILE
read $OPTS -N "read_t100k" -s 100k -f $TFILE
read $OPTS -N "read_u1k" -s 1k -f $VFILE
read $OPTS -N "read_u10k" -s 10k -f $VFILE
read $OPTS -N "read_u100k" -s 100k -f $VFILE
read $OPTS -N "read_z1k" -s 1k -f /dev/zero
read $OPTS -N "read_z10k" -s 10k -f /dev/zero
read $OPTS -N "read_z100k" -s 100k -f /dev/zero
read $OPTS -N "read_zw100k" -s 100k -w -f /dev/zero
write $OPTS -N "write_t1k" -s 1k -f $TFILE
write $OPTS -N "write_t10k" -s 10k -f $TFILE
write $OPTS -N "write_t100k" -s 100k -f $TFILE
write $OPTS -N "write_u1k" -s 1k -f $VFILE
write $OPTS -N "write_u10k" -s 10k -f $VFILE
write $OPTS -N "write_u100k" -s 100k -f $VFILE
write $OPTS -N "write_n1k" -s 1k -I 100 -B 0 -f /dev/null
write $OPTS -N "write_n10k" -s 10k -I 100 -B 0 -f /dev/null
write $OPTS -N "write_n100k" -s 100k -I 100 -B 0 -f /dev/null
writev $OPTS -N "writev_t1k" -s 1k -f $TFILE
writev $OPTS -N "writev_t10k" -s 10k -f $TFILE
writev $OPTS -N "writev_t100k" -s 100k -f $TFILE
writev $OPTS -N "writev_u1k" -s 1k -f $VFILE
writev $OPTS -N "writev_u10k" -s 10k -f $VFILE
writev $OPTS -N "writev_u100k" -s 100k -f $VFILE
writev $OPTS -N "writev_n1k" -s 1k -I 100 -B 0 -f /dev/null
writev $OPTS -N "writev_n10k" -s 10k -I 100 -B 0 -f /dev/null
writev $OPTS -N "writev_n100k" -s 100k -I 100 -B 0 -f /dev/null
pread $OPTS -N "pread_t1k" -s 1k -I 300 -f $TFILE
pread $OPTS -N "pread_t10k" -s 10k -I 1000 -f $TFILE
pread $OPTS -N "pread_t100k" -s 100k -I 10000 -f $TFILE
pread $OPTS -N "pread_u1k" -s 1k -I 300 -f $VFILE
pread $OPTS -N "pread_u10k" -s 10k -I 1000 -f $VFILE
pread $OPTS -N "pread_u100k" -s 100k -I 10000 -f $VFILE
pread $OPTS -N "pread_z1k" -s 1k -I 300 -f /dev/zero
pread $OPTS -N "pread_z10k" -s 10k -I 1000 -f /dev/zero
pread $OPTS -N "pread_z100k" -s 100k -I 2000 -f /dev/zero
pread $OPTS -N "pread_zw100k" -s 100k -w -I 10000 -f /dev/zero
pwrite $OPTS -N "pwrite_t1k" -s 1k -I 500 -f $TFILE
pwrite $OPTS -N "pwrite_t10k" -s 10k -I 1000 -f $TFILE
pwrite $OPTS -N "pwrite_t100k" -s 100k -I 10000 -f $TFILE
pwrite $OPTS -N "pwrite_u1k" -s 1k -I 500 -f $VFILE
pwrite $OPTS -N "pwrite_u10k" -s 10k -I 1000 -f $VFILE
pwrite $OPTS -N "pwrite_u100k" -s 100k -I 20000 -f $VFILE
pwrite $OPTS -N "pwrite_n1k" -s 1k -I 100 -f /dev/null
pwrite $OPTS -N "pwrite_n10k" -s 10k -I 100 -f /dev/null
pwrite $OPTS -N "pwrite_n100k" -s 100k -I 100 -f /dev/null
mmap $OPTS -N "mmap_z8k" -l 8k -I 1000 -f /dev/zero
mmap $OPTS -N "mmap_z128k" -l 128k -I 2000 -f /dev/zero
mmap $OPTS -N "mmap_t8k" -l 8k -I 1000 -f $TFILE
mmap $OPTS -N "mmap_t128k" -l 128k -I 1000 -f $TFILE
mmap $OPTS -N "mmap_u8k" -l 8k -I 1000 -f $VFILE
mmap $OPTS -N "mmap_u128k" -l 128k -I 1000 -f $VFILE
mmap $OPTS -N "mmap_a8k" -l 8k -I 200 -f MAP_ANON
mmap $OPTS -N "mmap_a128k" -l 128k -I 200 -f MAP_ANON
mmap $OPTS -N "mmap_rz8k" -l 8k -I 2000 -r -f /dev/zero
mmap $OPTS -N "mmap_rz128k" -l 128k -I 2000 -r -f /dev/zero
mmap $OPTS -N "mmap_rt8k" -l 8k -I 2000 -r -f $TFILE
mmap $OPTS -N "mmap_rt128k" -l 128k -I 20000 -r -f $TFILE
mmap $OPTS -N "mmap_ru8k" -l 8k -I 2000 -r -f $VFILE
mmap $OPTS -N "mmap_ru128k" -l 128k -I 20000 -r -f $VFILE
mmap $OPTS -N "mmap_ra8k" -l 8k -I 2000 -r -f MAP_ANON
mmap $OPTS -N "mmap_ra128k" -l 128k -I 20000 -r -f MAP_ANON
mmap $OPTS -N "mmap_wz8k" -l 8k -I 5000 -w -f /dev/zero
mmap $OPTS -N "mmap_wz128k" -l 128k -I 50000 -w -f /dev/zero
mmap $OPTS -N "mmap_wt8k" -l 8k -I 5000 -w -f $TFILE
mmap $OPTS -N "mmap_wt128k" -l 128k -I 50000 -w -f $TFILE
mmap $OPTS -N "mmap_wu8k" -l 8k -I 5000 -w -f $VFILE
mmap $OPTS -N "mmap_wu128k" -l 128k -I 500000 -w -f $VFILE
mmap $OPTS -N "mmap_wa8k" -l 8k -I 3000 -w -f MAP_ANON
mmap $OPTS -N "mmap_wa128k" -l 128k -I 50000 -w -f MAP_ANON
munmap $OPTS -N "unmap_z8k" -l 8k -I 500 -f /dev/zero
munmap $OPTS -N "unmap_z128k" -l 128k -I 500 -f /dev/zero
munmap $OPTS -N "unmap_t8k" -l 8k -I 500 -f $TFILE
munmap $OPTS -N "unmap_t128k" -l 128k -I 500 -f $TFILE
munmap $OPTS -N "unmap_u8k" -l 8k -I 500 -f $VFILE
munmap $OPTS -N "unmap_u128k" -l 128k -I 500 -f $VFILE
munmap $OPTS -N "unmap_a8k" -l 8k -I 500 -f MAP_ANON
munmap $OPTS -N "unmap_a128k" -l 128k -I 500 -f MAP_ANON
munmap $OPTS -N "unmap_rz8k" -l 8k -I 1000 -r -f /dev/zero
munmap $OPTS -N "unmap_rz128k" -l 128k -I 2000 -r -f /dev/zero
munmap $OPTS -N "unmap_rt8k" -l 8k -I 1000 -r -f $TFILE
munmap $OPTS -N "unmap_rt128k" -l 128k -I 3000 -r -f $TFILE
munmap $OPTS -N "unmap_ru8k" -l 8k -I 1000 -r -f $VFILE
munmap $OPTS -N "unmap_ru128k" -l 128k -I 3000 -r -f $VFILE
munmap $OPTS -N "unmap_ra8k" -l 8k -I 1000 -r -f MAP_ANON
munmap $OPTS -N "unmap_ra128k" -l 128k -I 2000 -r -f MAP_ANON
connection $OPTS -N "conn_connect" -B 256 -c
munmap $OPTS -N "unmap_wz8k" -l 8k -I 1000 -w -f /dev/zero
munmap $OPTS -N "unmap_wz128k" -l 128k -I 8000 -w -f /dev/zero
munmap $OPTS -N "unmap_wt8k" -l 8k -I 1000 -w -f $TFILE
munmap $OPTS -N "unmap_wt128k" -l 128k -I 10000 -w -f $TFILE
munmap $OPTS -N "unmap_wu8k" -l 8k -I 1000 -w -f $VFILE
munmap $OPTS -N "unmap_wu128k" -l 128k -I 50000 -w -f $VFILE
munmap $OPTS -N "unmap_wa8k" -l 8k -I 1000 -w -f MAP_ANON
munmap $OPTS -N "unmap_wa128k" -l 128k -I 10000 -w -f MAP_ANON
mprotect $OPTS -N "mprot_z8k" -l 8k -I 300 -f /dev/zero
mprotect $OPTS -N "mprot_z128k" -l 128k -I 500 -f /dev/zero
mprotect $OPTS -N "mprot_wz8k" -l 8k -I 500 -w -f /dev/zero
mprotect $OPTS -N "mprot_wz128k" -l 128k -I 1000 -w -f /dev/zero
mprotect $OPTS -N "mprot_twz8k" -l 8k -I 1000 -w -t -f /dev/zero
mprotect $OPTS -N "mprot_tw128k" -l 128k -I 2000 -w -t -f /dev/zero
mprotect $OPTS -N "mprot_tw4m" -l 4m -w -t -B 1 -f /dev/zero
pipe $OPTS -N "pipe_pst1" -s 1 -I 1000 -x pipe -m st
pipe $OPTS -N "pipe_pmt1" -s 1 -I 8000 -x pipe -m mt
pipe $OPTS -N "pipe_pmp1" -s 1 -I 8000 -x pipe -m mp
pipe $OPTS -N "pipe_pst4k" -s 4k -I 1000 -x pipe -m st
pipe $OPTS -N "pipe_pmt4k" -s 4k -I 8000 -x pipe -m mt
pipe $OPTS -N "pipe_pmp4k" -s 4k -I 8000 -x pipe -m mp
pipe $OPTS -N "pipe_sst1" -s 1 -I 1000 -x sock -m st
pipe $OPTS -N "pipe_smt1" -s 1 -I 8000 -x sock -m mt
pipe $OPTS -N "pipe_smp1" -s 1 -I 8000 -x sock -m mp
pipe $OPTS -N "pipe_sst4k" -s 4k -I 1000 -x sock -m st
pipe $OPTS -N "pipe_smt4k" -s 4k -I 8000 -x sock -m mt
pipe $OPTS -N "pipe_smp4k" -s 4k -I 8000 -x sock -m mp
pipe $OPTS -N "pipe_tst1" -s 1 -I 1000 -x tcp -m st
pipe $OPTS -N "pipe_tmt1" -s 1 -I 8000 -x tcp -m mt
pipe $OPTS -N "pipe_tmp1" -s 1 -I 8000 -x tcp -m mp
pipe $OPTS -N "pipe_tst4k" -s 4k -I 1000 -x tcp -m st
pipe $OPTS -N "pipe_tmt4k" -s 4k -I 8000 -x tcp -m mt
pipe $OPTS -N "pipe_tmp4k" -s 4k -I 8000 -x tcp -m mp
connection $OPTS -N "conn_accept" -B 256 -a
close_tcp $OPTS -N "close_tcp" -B 32
.

View File

@ -1,46 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* default implementation (nop) of benchmark_fini
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "libmicro.h"
int
benchmark_fini()
{
return (0);
}

View File

@ -1,46 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* default implementation (nop) of benchmark_finibatch
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "libmicro.h"
/*ARGSUSED*/
int
benchmark_finibatch(void *tsd)
{
return (0);
}

View File

@ -1,45 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* default implementation (nop) of benchmark_finirun
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "libmicro.h"
int
benchmark_finirun()
{
return (0);
}

View File

@ -1,46 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* default implementation (nop) of benchmark_finiworker
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "libmicro.h"
/*ARGSUSED*/
int
benchmark_finiworker(void *tsd)
{
return (0);
}

View File

@ -1,46 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* default implementation (nop) of benchmark_init
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "libmicro.h"
int
benchmark_init()
{
return (0);
}

View File

@ -1,47 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* default implementation (nop) of benchmark_initbatch
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "libmicro.h"
/*ARGSUSED*/
int
benchmark_initbatch(void *tsd)
{
return (0);
}

View File

@ -1,45 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* default implementation (nop) of benchmark_initrun
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "libmicro.h"
int
benchmark_initrun()
{
return (0);
}

View File

@ -1,46 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* default implementation (nop) of benchmark_initworker
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "libmicro.h"
/*ARGSUSED*/
int
benchmark_initworker(void *tsd)
{
return (0);
}

View File

@ -1,46 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* default implementation (nop) of benchmark_optswitch
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "libmicro.h"
/*ARGSUSED*/
int
benchmark_optswitch(int opt, char *optarg)
{
return (0);
}

View File

@ -1,47 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* default implementation (nop) of benchmark_result
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "libmicro.h"
char *
benchmark_result()
{
static char result = '\0';
return (&result);
}

View File

@ -1,163 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* benchmark for bind... keep in mind tcp hash chain effects
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include "libmicro.h"
#define FIRSTPORT 12345
typedef struct {
int *ts_lsns;
struct sockaddr_in *ts_adds;
} tsd_t;
static int optz = -0;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
lm_defB = 256;
(void) sprintf(lm_optstr, "z");
(void) sprintf(lm_usage,
" [-z bind to port 0 rather than seq. number\n"
"notes: measures bind() on TCP");
return (0);
}
int
benchmark_initrun()
{
(void) setfdlimit(lm_optB * lm_optT + 10);
return (0);
}
/*ARGSUSED*/
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'z':
optz = 1;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i, j;
int opt = 1;
struct hostent *host;
int errors = 0;
ts->ts_lsns = (int *)malloc(lm_optB * sizeof (int));
if (ts->ts_lsns == NULL)
errors ++;
ts->ts_adds = (struct sockaddr_in *)malloc(lm_optB *
sizeof (struct sockaddr_in));
if (ts->ts_adds == NULL)
errors ++;
j = FIRSTPORT;
for (i = 0; i < lm_optB; i++) {
if ((ts->ts_lsns[i] = socket(PF_INET, SOCK_STREAM, 0)) == -1)
errors ++;
if (setsockopt(ts->ts_lsns[i], SOL_SOCKET, SO_REUSEADDR,
&opt, sizeof (int)) == -1)
errors ++;
if ((host = gethostbyname("localhost")) == NULL)
errors ++;
(void) memset(&ts->ts_adds[i], 0,
sizeof (struct sockaddr_in));
ts->ts_adds[i].sin_family = AF_INET;
ts->ts_adds[i].sin_port = (optz ? 0 : htons(j++));
(void) memcpy(&ts->ts_adds[i].sin_addr.s_addr,
host->h_addr_list[0], sizeof (struct in_addr));
}
return (errors);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++) {
if ((bind(ts->ts_lsns[i],
(struct sockaddr *)&ts->ts_adds[i],
sizeof (struct sockaddr_in)) != 0) &&
(errno != EADDRINUSE))
res->re_errors ++;
}
res->re_count = i;
return (0);
}
int
benchmark_finibatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++)
(void) close(ts->ts_lsns[i]);
return (0);
}

View File

@ -1,222 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* routine to benchmark cache-to-cache transfer times... uses
* solaris features to find and bind to cpus in the current
* processor set, so not likely to work elsewhere.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include <sys/processor.h>
#include <sys/types.h>
#include <stdio.h>
#include <errno.h>
#include <sys/pset.h>
#include "libmicro.h"
static long opts = 1024*512;
typedef struct {
long **ts_data;
long ts_result;
pthread_mutex_t ts_lock;
} tsd_t;
static unsigned int ncpu = 1024;
static tsd_t *thread_data[1024];
static processorid_t cpus[1024];
int traverse_ptrchain(long **, int, int);
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "s:");
(void) sprintf(lm_usage,
" [-s size] size of access area in bytes"
" (default %ld)\n"
"notes: measures cache to cache transfer times on Solaris\n",
opts);
(void) sprintf(lm_header, "%8s", "size");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 's':
opts = sizetoint(optarg);
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
if (pset_info(PS_MYID, NULL, &ncpu, cpus) < 0) {
perror("pset_info");
return (1);
}
return (0);
}
int
benchmark_initworker(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i, j;
processorid_t cpu;
ts->ts_data = malloc(opts);
if (ts->ts_data == NULL) {
return (1);
}
(void) pthread_mutex_init(&ts->ts_lock, NULL);
if (processor_bind(P_LWPID, P_MYID,
cpu = cpus[(pthread_self() - 1) % ncpu],
NULL) < 0) {
perror("processor_bind:");
return (1);
}
(void) printf("# thread %d using processor %d\n", pthread_self(), cpu);
/*
* use lmbench style backwards stride
*/
for (i = 0; i < opts / sizeof (long); i++) {
j = i - 128;
if (j < 0)
j = j + opts / sizeof (long);
ts->ts_data[i] = (long *)&(ts->ts_data[j]);
}
thread_data[pthread_self() - 1] = ts;
return (0);
}
/*
* here we go in order for each thread, causing inherent serialization
* this is normally not a good idea, but in this case we're trying to
* measure cache-to-cache transfer times, and if we run threads in
* parallel we're likely to see saturation effects rather than cache-to-cache,
* esp. on wimpy memory platforms like P4.
*/
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts;
int i, j;
int count = opts / 128 / sizeof (long);
for (j = 0; j < lm_optB; j++)
for (i = 0; i < lm_optT; i++) {
ts = thread_data[i];
(void) pthread_mutex_lock(&ts->ts_lock);
ts->ts_result += traverse_ptrchain(
(long **)ts->ts_data, count, 0);
(void) pthread_mutex_unlock(&ts->ts_lock);
}
res->re_count = lm_optB * lm_optT * count;
return (0);
}
int
traverse_ptrchain(long **ptr, int count, int value)
{
int i;
for (i = 0; i < count; i += 10) {
*ptr = *ptr + value;
ptr = (long **)*ptr;
*ptr = *ptr + value;
ptr = (long **)*ptr;
*ptr = *ptr + value;
ptr = (long **)*ptr;
*ptr = *ptr + value;
ptr = (long **)*ptr;
*ptr = *ptr + value;
ptr = (long **)*ptr;
*ptr = *ptr + value;
ptr = (long **)*ptr;
*ptr = *ptr + value;
ptr = (long **)*ptr;
*ptr = *ptr + value;
ptr = (long **)*ptr;
*ptr = *ptr + value;
ptr = (long **)*ptr;
*ptr = *ptr + value;
ptr = (long **)*ptr;
*ptr = *ptr + value;
}
return ((int)*ptr); /* bogus return */
}
char *
benchmark_result()
{
static char result[256];
(void) sprintf(result, "%8ld ", opts);
return (result);
}

View File

@ -1,278 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* The "cascade" test case is a multiprocess/multithread batten-passing model
* using lock primitives alone for synchronisation. Threads are arranged in a
* ring. Each thread has two locks of its own on which it blocks, and is able
* to manipulate the two locks belonging to the thread which follows it in the
* ring.
*
* The number of threads (nthreads) is specified by the generic libMicro -P/-T
* options. With nthreads == 1 (the default) the uncontended case can be timed.
*
* The main logic is generic and allows any simple blocking API to be tested.
* The API-specific component is clearly indicated.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <sys/mman.h>
#include "libmicro.h"
typedef struct {
int ts_once;
int ts_id;
int ts_us0; /* our lock indices */
int ts_us1;
int ts_them0; /* their lock indices */
int ts_them1;
} tsd_t;
static int nthreads;
/*
* API-specific code BEGINS here
*/
static int opto = 0;
static int opts = 0;
static int nlocks;
static pthread_mutex_t *mxs;
static pthread_cond_t *cvs;
static int *conds;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "os");
lm_defN = "cscd_cond";
(void) sprintf(lm_usage,
" [-o] (do signal outside mutex)\n"
" [-s] (force PTHREAD_PROCESS_SHARED)\n"
"notes: thread cascade using pthread_conds\n");
return (0);
}
/*ARGSUSED*/
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'o':
opto = 1;
break;
case 's':
opts = 1;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
int i;
int e = 0;
pthread_mutexattr_t ma;
pthread_condattr_t ca;
nthreads = lm_optP * lm_optT;
nlocks = nthreads * 2;
/*LINTED*/
mxs = (pthread_mutex_t *)mmap(NULL,
nlocks * sizeof (pthread_mutex_t),
PROT_READ | PROT_WRITE,
MAP_ANON | MAP_SHARED,
-1, 0L);
if (mxs == MAP_FAILED) {
return (1);
}
/*LINTED*/
cvs = (pthread_cond_t *)mmap(NULL,
nlocks * sizeof (pthread_cond_t),
PROT_READ | PROT_WRITE,
MAP_ANON | MAP_SHARED,
-1, 0L);
if (cvs == MAP_FAILED) {
return (1);
}
/*LINTED*/
conds = (int *)mmap(NULL,
nlocks * sizeof (pthread_cond_t),
PROT_READ | PROT_WRITE,
MAP_ANON | MAP_SHARED,
-1, 0L);
if (conds == MAP_FAILED) {
return (1);
}
(void) pthread_mutexattr_init(&ma);
(void) pthread_condattr_init(&ca);
if (lm_optP > 1 || opts) {
(void) pthread_mutexattr_setpshared(&ma,
PTHREAD_PROCESS_SHARED);
(void) pthread_condattr_setpshared(&ca,
PTHREAD_PROCESS_SHARED);
} else {
(void) pthread_mutexattr_setpshared(&ma,
PTHREAD_PROCESS_PRIVATE);
(void) pthread_condattr_setpshared(&ca,
PTHREAD_PROCESS_PRIVATE);
}
for (i = 0; i < nlocks; i++) {
(void) pthread_mutex_init(&mxs[i], &ma);
(void) pthread_cond_init(&cvs[i], &ca);
conds[i] = 0;
}
return (e);
}
int
block(int index)
{
(void) pthread_mutex_lock(&mxs[index]);
while (conds[index] != 0) {
(void) pthread_cond_wait(&cvs[index], &mxs[index]);
}
conds[index] = 1;
(void) pthread_mutex_unlock(&mxs[index]);
return (0);
}
int
unblock(int index)
{
(void) pthread_mutex_lock(&mxs[index]);
conds[index] = 0;
if (opto) {
(void) pthread_mutex_unlock(&mxs[index]);
(void) pthread_cond_signal(&cvs[index]);
} else {
(void) pthread_cond_signal(&cvs[index]);
(void) pthread_mutex_unlock(&mxs[index]);
}
return (0);
}
/*
* API-specific code ENDS here
*/
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int e = 0;
if (ts->ts_once == 0) {
int us, them;
us = (getpindex() * lm_optT) + gettindex();
them = (us + 1) % (lm_optP * lm_optT);
ts->ts_id = us;
/* lock index asignment for us and them */
ts->ts_us0 = (us * 2);
ts->ts_us1 = (us * 2) + 1;
if (us < nthreads - 1) {
/* straight-thru connection to them */
ts->ts_them0 = (them * 2);
ts->ts_them1 = (them * 2) + 1;
} else {
/* cross-over connection to them */
ts->ts_them0 = (them * 2) + 1;
ts->ts_them1 = (them * 2);
}
ts->ts_once = 1;
}
/* block their first move */
e += block(ts->ts_them0);
return (e);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int e = 0;
/* wait to be unblocked (id == 0 will not block) */
e += block(ts->ts_us0);
for (i = 0; i < lm_optB; i += 2) {
/* allow them to block us again */
e += unblock(ts->ts_us0);
/* block their next + 1 move */
e += block(ts->ts_them1);
/* unblock their next move */
e += unblock(ts->ts_them0);
/* wait for them to unblock us */
e += block(ts->ts_us1);
/* repeat with locks reversed */
e += unblock(ts->ts_us1);
e += block(ts->ts_them0);
e += unblock(ts->ts_them1);
e += block(ts->ts_us0);
}
/* finish batch with nothing blocked */
e += unblock(ts->ts_them0);
e += unblock(ts->ts_us0);
res->re_count = i;
res->re_errors = e;
return (0);
}

View File

@ -1,232 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* The "cascade" test case is a multiprocess/multithread batten-passing model
* using lock primitives alone for synchronisation. Threads are arranged in a
* ring. Each thread has two locks of its own on which it blocks, and is able
* to manipulate the two locks belonging to the thread which follows it in the
* ring.
*
* The number of threads (nthreads) is specified by the generic libMicro -P/-T
* options. With nthreads == 1 (the default) the uncontended case can be timed.
*
* The main logic is generic and allows any simple blocking API to be tested.
* The API-specific component is clearly indicated.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include "libmicro.h"
typedef struct {
int ts_once;
int ts_id;
int ts_us0; /* our lock indices */
int ts_us1;
int ts_them0; /* their lock indices */
int ts_them1;
} tsd_t;
static int nthreads;
/*
* API-specific code BEGINS here
*/
#define DEFD "/tmp"
static char *optd = DEFD;
static int file;
static int nlocks;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "d:");
lm_defN = "cscd_fcntl";
(void) sprintf(lm_usage,
" [-d directory for temp file (default %s)]\n"
"notes: thread cascade using fcntl region locking\n",
DEFD);
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'd':
optd = optarg;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
int errors = 0;
char fname[1024];
nthreads = lm_optP * lm_optT;
nlocks = nthreads * 2;
(void) sprintf(fname, "%s/cascade.%ld", optd, getpid());
file = open(fname, O_CREAT | O_TRUNC | O_RDWR, 0600);
if (file == -1) {
errors++;
}
if (unlink(fname)) {
errors++;
}
if (ftruncate(file, nlocks * 3) == -1) {
errors++;
}
return (errors);
}
int
block(int index)
{
struct flock fl;
fl.l_type = F_WRLCK;
fl.l_whence = SEEK_SET;
fl.l_start = index;
fl.l_len = 1;
return (fcntl(file, F_SETLKW, &fl) == -1);
}
int
unblock(int index)
{
struct flock fl;
fl.l_type = F_UNLCK;
fl.l_whence = SEEK_SET;
fl.l_start = index;
fl.l_len = 1;
return (fcntl(file, F_SETLK, &fl) == -1);
}
/*
* API-specific code ENDS here
*/
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int e = 0;
if (ts->ts_once == 0) {
int us, them;
us = (getpindex() * lm_optT) + gettindex();
them = (us + 1) % (lm_optP * lm_optT);
ts->ts_id = us;
/* lock index asignment for us and them */
ts->ts_us0 = (us * 4);
ts->ts_us1 = (us * 4) + 2;
if (us < nthreads - 1) {
/* straight-thru connection to them */
ts->ts_them0 = (them * 4);
ts->ts_them1 = (them * 4) + 2;
} else {
/* cross-over connection to them */
ts->ts_them0 = (them * 4) + 2;
ts->ts_them1 = (them * 4);
}
ts->ts_once = 1;
}
/* block their first move */
e += block(ts->ts_them0);
return (e);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int e = 0;
/* wait to be unblocked (id == 0 will not block) */
e += block(ts->ts_us0);
for (i = 0; i < lm_optB; i += 2) {
/* allow them to block us again */
e += unblock(ts->ts_us0);
/* block their next + 1 move */
e += block(ts->ts_them1);
/* unblock their next move */
e += unblock(ts->ts_them0);
/* wait for them to unblock us */
e += block(ts->ts_us1);
/* repeat with locks reversed */
e += unblock(ts->ts_us1);
e += block(ts->ts_them0);
e += unblock(ts->ts_them1);
e += block(ts->ts_us0);
}
/* finish batch with nothing blocked */
e += unblock(ts->ts_them0);
e += unblock(ts->ts_us0);
res->re_count = i;
res->re_errors = e;
return (0);
}

View File

@ -1,229 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* The "cascade" test case is a multiprocess/multithread batten-passing model
* using lock primitives alone for synchronisation. Threads are arranged in a
* ring. Each thread has two locks of its own on which it blocks, and is able
* to manipulate the two locks belonging to the thread which follows it in the
* ring.
*
* The number of threads (nthreads) is specified by the generic libMicro -P/-T
* options. With nthreads == 1 (the default) the uncontended case can be timed.
*
* The main logic is generic and allows any simple blocking API to be tested.
* The API-specific component is clearly indicated.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/file.h>
#include "libmicro.h"
#ifndef LOCK_EX
#include "/usr/ucbinclude/sys/file.h"
extern int flock(int fd, int operation);
#endif
typedef struct {
int ts_once;
int ts_id;
int ts_us0; /* our lock indices */
int ts_us1;
int ts_them0; /* their lock indices */
int ts_them1;
} tsd_t;
static int nthreads;
/*
* API-specific code BEGINS here
*/
#define DEFD "/tmp"
static char *optd = DEFD;
static int nfiles;
static int *files;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "d:");
lm_defN = "cscd_flock";
(void) sprintf(lm_usage,
" [-d directory for temp files (default %s)]\n"
"notes: thread cascade using flock file locking\n",
DEFD);
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'd':
optd = optarg;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
int i;
int errors = 0;
char fname[1024];
nthreads = lm_optP * lm_optT;
nfiles = nthreads * 2;
(void) setfdlimit(nfiles + 10);
files = (int *)malloc(nfiles * sizeof (int));
if (files == NULL) {
return (1);
}
(void) sprintf(fname, "%s/cascade.%ld", optd, getpid());
for (i = 0; i < nfiles; i++) {
files[i] = open(fname, O_CREAT | O_TRUNC | O_RDWR, 0600);
if (files[i] == -1) {
errors++;
}
if (unlink(fname)) {
errors++;
}
}
return (errors);
}
int
block(int index)
{
return (flock(files[index], LOCK_EX) == -1);
}
int
unblock(int index)
{
return (flock(files[index], LOCK_UN) == -1);
}
/*
* API-specific code ENDS here
*/
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int e = 0;
if (ts->ts_once == 0) {
int us, them;
us = (getpindex() * lm_optT) + gettindex();
them = (us + 1) % (lm_optP * lm_optT);
ts->ts_id = us;
/* lock index asignment for us and them */
ts->ts_us0 = (us * 2);
ts->ts_us1 = (us * 2) + 1;
if (us < nthreads - 1) {
/* straight-thru connection to them */
ts->ts_them0 = (them * 2);
ts->ts_them1 = (them * 2) + 1;
} else {
/* cross-over connection to them */
ts->ts_them0 = (them * 2) + 1;
ts->ts_them1 = (them * 2);
}
ts->ts_once = 1;
}
/* block their first move */
e += block(ts->ts_them0);
return (e);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int e = 0;
/* wait to be unblocked (id == 0 will not block) */
e += block(ts->ts_us0);
for (i = 0; i < lm_optB; i += 2) {
/* allow them to block us again */
e += unblock(ts->ts_us0);
/* block their next + 1 move */
e += block(ts->ts_them1);
/* unblock their next move */
e += unblock(ts->ts_them0);
/* wait for them to unblock us */
e += block(ts->ts_us1);
/* repeat with locks reversed */
e += unblock(ts->ts_us1);
e += block(ts->ts_them0);
e += unblock(ts->ts_them1);
e += block(ts->ts_us0);
}
/* finish batch with nothing blocked */
e += unblock(ts->ts_them0);
e += unblock(ts->ts_us0);
res->re_count = i;
res->re_errors = e;
return (0);
}

View File

@ -1,223 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* The "cascade" test case is a multiprocess/multithread batten-passing model
* using lock primitives alone for synchronisation. Threads are arranged in a
* ring. Each thread has two locks of its own on which it blocks, and is able
* to manipulate the two locks belonging to the thread which follows it in the
* ring.
*
* The number of threads (nthreads) is specified by the generic libMicro -P/-T
* options. With nthreads == 1 (the default) the uncontended case can be timed.
*
* The main logic is generic and allows any simple blocking API to be tested.
* The API-specific component is clearly indicated.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include "libmicro.h"
typedef struct {
int ts_once;
int ts_id;
int ts_us0; /* our lock indices */
int ts_us1;
int ts_them0; /* their lock indices */
int ts_them1;
} tsd_t;
static int nthreads;
/*
* API-specific code BEGINS here
*/
#define DEFD "/tmp"
static char *optd = DEFD;
static int nfiles;
static int *files;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "d:");
lm_defN = "cscd_lockf";
(void) sprintf(lm_usage,
" [-d directory for temp files (default %s)]\n"
"notes: thread cascade using lockf file locking\n",
DEFD);
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'd':
optd = optarg;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
int i;
int errors = 0;
char fname[1024];
nthreads = lm_optP * lm_optT;
nfiles = nthreads * 2;
(void) setfdlimit(nfiles + 10);
files = (int *)malloc(nfiles * sizeof (int));
if (files == NULL) {
return (1);
}
(void) sprintf(fname, "%s/cascade.%ld", optd, getpid());
for (i = 0; i < nfiles; i++) {
files[i] = open(fname, O_CREAT | O_TRUNC | O_RDWR, 0600);
if (files[i] == -1) {
errors++;
}
if (unlink(fname)) {
errors++;
}
}
return (errors);
}
int
block(int index)
{
return (lockf(files[index], F_LOCK, 0) == -1);
}
int
unblock(int index)
{
return (lockf(files[index], F_ULOCK, 0) == -1);
}
/*
* API-specific code ENDS here
*/
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int e = 0;
if (ts->ts_once == 0) {
int us, them;
us = (getpindex() * lm_optT) + gettindex();
them = (us + 1) % (lm_optP * lm_optT);
ts->ts_id = us;
/* lock index asignment for us and them */
ts->ts_us0 = (us * 2);
ts->ts_us1 = (us * 2) + 1;
if (us < nthreads - 1) {
/* straight-thru connection to them */
ts->ts_them0 = (them * 2);
ts->ts_them1 = (them * 2) + 1;
} else {
/* cross-over connection to them */
ts->ts_them0 = (them * 2) + 1;
ts->ts_them1 = (them * 2);
}
ts->ts_once = 1;
}
/* block their first move */
e += block(ts->ts_them0);
return (e);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int e = 0;
/* wait to be unblocked (id == 0 will not block) */
e += block(ts->ts_us0);
for (i = 0; i < lm_optB; i += 2) {
/* allow them to block us again */
e += unblock(ts->ts_us0);
/* block their next + 1 move */
e += block(ts->ts_them1);
/* unblock their next move */
e += unblock(ts->ts_them0);
/* wait for them to unblock us */
e += block(ts->ts_us1);
/* repeat with locks reversed */
e += unblock(ts->ts_us1);
e += block(ts->ts_them0);
e += unblock(ts->ts_them1);
e += block(ts->ts_us0);
}
/* finish batch with nothing blocked */
e += unblock(ts->ts_them0);
e += unblock(ts->ts_us0);
res->re_count = i;
res->re_errors = e;
return (0);
}

View File

@ -1,227 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* The "cascade" test case is a multiprocess/multithread batten-passing model
* using lock primitives alone for synchronisation. Threads are arranged in a
* ring. Each thread has two locks of its own on which it blocks, and is able
* to manipulate the two locks belonging to the thread which follows it in the
* ring.
*
* The number of threads (nthreads) is specified by the generic libMicro -P/-T
* options. With nthreads == 1 (the default) the uncontended case can be timed.
*
* The main logic is generic and allows any simple blocking API to be tested.
* The API-specific component is clearly indicated.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <sys/mman.h>
#include "libmicro.h"
typedef struct {
int ts_once;
int ts_id;
int ts_us0; /* our lock indices */
int ts_us1;
int ts_them0; /* their lock indices */
int ts_them1;
} tsd_t;
static int nthreads;
/*
* API-specific code BEGINS here
*/
static int opts = 0;
static int nlocks;
static pthread_mutex_t *locks;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "s");
lm_defN = "cscd_mutex";
(void) sprintf(lm_usage,
" [-s] (force PTHREAD_PROCESS_SHARED)\n"
"notes: thread cascade using pthread_mutexes\n");
return (0);
}
/*ARGSUSED*/
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 's':
opts = 1;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
int i;
int e = 0;
pthread_mutexattr_t ma;
nthreads = lm_optP * lm_optT;
nlocks = nthreads * 2;
/*LINTED*/
locks = (pthread_mutex_t *)mmap(NULL,
nlocks * sizeof (pthread_mutex_t),
PROT_READ | PROT_WRITE,
MAP_ANON | MAP_SHARED,
-1, 0L);
if (locks == MAP_FAILED) {
return (1);
}
(void) pthread_mutexattr_init(&ma);
if (lm_optP > 1 || opts) {
(void) pthread_mutexattr_setpshared(&ma,
PTHREAD_PROCESS_SHARED);
} else {
(void) pthread_mutexattr_setpshared(&ma,
PTHREAD_PROCESS_PRIVATE);
}
for (i = 0; i < nlocks; i++) {
(void) pthread_mutex_init(&locks[i], &ma);
}
return (e);
}
int
block(int index)
{
return (pthread_mutex_lock(&locks[index]) == -1);
}
int
unblock(int index)
{
return (pthread_mutex_unlock(&locks[index]) == -1);
}
/*
* API-specific code ENDS here
*/
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int e = 0;
if (ts->ts_once == 0) {
int us, them;
us = (getpindex() * lm_optT) + gettindex();
them = (us + 1) % (lm_optP * lm_optT);
ts->ts_id = us;
/* lock index asignment for us and them */
ts->ts_us0 = (us * 2);
ts->ts_us1 = (us * 2) + 1;
if (us < nthreads - 1) {
/* straight-thru connection to them */
ts->ts_them0 = (them * 2);
ts->ts_them1 = (them * 2) + 1;
} else {
/* cross-over connection to them */
ts->ts_them0 = (them * 2) + 1;
ts->ts_them1 = (them * 2);
}
ts->ts_once = 1;
}
/* block their first move */
e += block(ts->ts_them0);
return (e);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int e = 0;
/* wait to be unblocked (id == 0 will not block) */
e += block(ts->ts_us0);
for (i = 0; i < lm_optB; i += 2) {
/* allow them to block us again */
e += unblock(ts->ts_us0);
/* block their next + 1 move */
e += block(ts->ts_them1);
/* unblock their next move */
e += unblock(ts->ts_them0);
/* wait for them to unblock us */
e += block(ts->ts_us1);
/* repeat with locks reversed */
e += unblock(ts->ts_us1);
e += block(ts->ts_them0);
e += unblock(ts->ts_them1);
e += block(ts->ts_us0);
}
/* finish batch with nothing blocked */
e += unblock(ts->ts_them0);
e += unblock(ts->ts_us0);
res->re_count = i;
res->re_errors = e;
return (0);
}

View File

@ -1,132 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* change directory benchmark
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "libmicro.h"
#define DEFAULTDIR "/"
#define MAXPATHLEN 1024
static int optg = 0;
static int dircount;
static char ** dirlist;
int
benchmark_init()
{
(void) sprintf(lm_optstr, "g");
lm_tsdsize = 0;
(void) sprintf(lm_usage,
" [-g] (do getcwd() also)\n"
" directory ... (default = %s)\n"
"notes: measures chdir() and (optionally) getcwd()",
DEFAULTDIR);
(void) sprintf(lm_header, "%5s %5s", "dirs", "gets");
return (0);
}
/*ARGSUSED*/
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'g':
optg = 1;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
extern int optind;
int i;
dircount = lm_argc - optind;
if (dircount <= 0) {
dirlist = (char **)malloc(sizeof (char *));
dirlist[0] = DEFAULTDIR;
dircount = 1;
} else {
dirlist = (char **)malloc(dircount * sizeof (char *));
for (i = 0; i < dircount; i++) {
dirlist[i] = lm_argv[optind++];
}
}
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i, j;
char buf[MAXPATHLEN];
j = 0;
for (i = 0; i < lm_optB; i++) {
if (chdir(dirlist[j]) == -1)
res->re_errors++;
j++;
j %= dircount;
if (optg && (getcwd(buf, MAXPATHLEN) == NULL)) {
res->re_errors++;
}
}
res->re_count = i;
return (0);
}
char *
benchmark_result()
{
static char result[256];
(void) sprintf(result, "%5d %5s", dircount, optg ? "y" : "n");
return (result);
}

View File

@ -1,141 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* benchmark for close
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include "libmicro.h"
#define DEFF "/dev/null"
static char *optf = DEFF;
static int optb = 0;
typedef struct {
int *ts_fds;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
lm_defB = 256;
(void) sprintf(lm_optstr, "f:b");
(void) sprintf(lm_usage,
" [-f file-to-close (default %s)]\n"
" [-b] (try to close an unopened fd)\n"
"notes: measures close()",
DEFF);
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'f':
optf = optarg;
break;
case 'b':
optb = 1;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
(void) setfdlimit(lm_optB * lm_optT + 10);
return (0);
}
int
benchmark_initworker(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
ts->ts_fds = (int *)malloc(lm_optB * sizeof (int));
if (ts->ts_fds == NULL) {
return (1);
}
return (0);
}
/*
* don't need a finiworker; we're exiting anyway
*/
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int errors = 0;
for (i = 0; i < lm_optB; i++) {
ts->ts_fds[i] = ((optb == 0) ?
open(optf, O_RDONLY) : i + 1024);
if (ts->ts_fds[i] == -1) {
errors++;
}
}
return (errors);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++) {
if (close(ts->ts_fds[i]) == -1 && !optb) {
res->re_errors++;
}
}
res->re_count = i;
return (0);
}

View File

@ -1,241 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* benchmark to measure time to close a local tcp connection
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include "libmicro.h"
#define FIRSTPORT 12345
typedef struct {
int *ts_lsns;
int *ts_accs;
int *ts_cons;
struct sockaddr_in *ts_adds;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
lm_defB = 256;
(void) sprintf(lm_usage,
"notes: measures close() on local TCP connections");
return (0);
}
int
benchmark_initrun()
{
(void) setfdlimit(3 * lm_optB * lm_optT + 10);
return (0);
}
int
benchmark_initworker(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i, j;
int opt = 1;
struct hostent *host;
int errors = 0;
ts->ts_lsns = (int *)malloc(lm_optB * sizeof (int));
if (ts->ts_lsns == NULL) {
errors ++;
}
ts->ts_accs = (int *)malloc(lm_optB * sizeof (int));
if (ts->ts_accs == NULL) {
errors ++;
}
ts->ts_cons = (int *)malloc(lm_optB * sizeof (int));
if (ts->ts_cons == NULL) {
errors ++;
}
ts->ts_adds = (struct sockaddr_in *)malloc(lm_optB *
sizeof (struct sockaddr_in));
if (ts->ts_adds == NULL) {
errors ++;
}
j = FIRSTPORT;
for (i = 0; i < lm_optB; i++) {
ts->ts_lsns[i] = socket(AF_INET, SOCK_STREAM, 0);
if (ts->ts_lsns[i] == -1) {
perror("socket");
errors ++;
}
if (setsockopt(ts->ts_lsns[i], SOL_SOCKET, SO_REUSEADDR,
&opt, sizeof (int)) == -1) {
perror("setsockopt");
errors ++;
}
if ((host = gethostbyname("localhost")) == NULL) {
errors ++;
}
for (;;) {
(void) memset(&ts->ts_adds[i], 0,
sizeof (struct sockaddr_in));
ts->ts_adds[i].sin_family = AF_INET;
ts->ts_adds[i].sin_port = htons(j++);
(void) memcpy(&ts->ts_adds[i].sin_addr.s_addr,
host->h_addr_list[0], sizeof (struct in_addr));
if (bind(ts->ts_lsns[i],
(struct sockaddr *)&ts->ts_adds[i],
sizeof (struct sockaddr_in)) == 0) {
break;
}
if (errno != EADDRINUSE) {
perror("bind");
errors ++;
}
}
if (listen(ts->ts_lsns[i], 5) == -1) {
perror("listen");
errors ++;
}
}
return (errors);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int result;
struct sockaddr_in addr;
socklen_t size;
int errors = 0;
for (i = 0; i < lm_optB; i++) {
ts->ts_cons[i] = socket(AF_INET, SOCK_STREAM, 0);
if (ts->ts_cons[i] == -1) {
perror("socket");
errors ++;
continue;
}
if (fcntl(ts->ts_cons[i], F_SETFL, O_NDELAY) == -1) {
perror("fcnt");
errors ++;
continue;
}
result = connect(ts->ts_cons[i],
(struct sockaddr *)&ts->ts_adds[i],
sizeof (struct sockaddr_in));
if ((result == -1) && (errno != EINPROGRESS)) {
perror("connect");
errors ++;
continue;
}
size = sizeof (struct sockaddr);
result = accept(ts->ts_lsns[i], (struct sockaddr *)&addr,
&size);
if (result == -1) {
perror("accept");
errors ++;
continue;
}
ts->ts_accs[i] = result;
}
return (errors);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++) {
if (close(ts->ts_accs[i]) == -1) {
res->re_errors ++;
}
}
res->re_count = i;
return (0);
}
int
benchmark_finibatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++) {
(void) close(ts->ts_cons[i]);
}
return (0);
}
int
benchmark_finiworker(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++) {
(void) close(ts->ts_lsns[i]);
}
return (0);
}

View File

@ -1,12 +0,0 @@
#ifndef CONFIG_LIBMICRO_H
#define CONFIG_LIBMICRO_H
#ifndef O_NDELAY
#define O_NDELAY O_NONBLOCK
#endif
#ifndef PF_UNIX
#define PF_UNIX AF_UNIX
#endif
#endif /* CONFIG_LIBMICRO_H */

View File

@ -1,305 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/poll.h>
#include "libmicro.h"
#define FIRSTPORT 12345
typedef struct {
int ts_once;
int *ts_lsns;
int *ts_accs;
int *ts_cons;
struct sockaddr_in *ts_adds;
} tsd_t;
static int opta = 0;
static int optc = 0;
static struct hostent *host;
int
benchmark_init()
{
lm_defB = 256;
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "ac");
(void) sprintf(lm_usage,
" [-a] (measure accept() only)\n"
" [-c] (measure connect() only)\n"
"notes: measures connect()/accept()\n");
return (0);
}
/*ARGSUSED*/
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'a':
opta = 1;
break;
case 'c':
optc = 1;
break;
default:
return (-1);
}
if (opta && optc) {
(void) printf("warning: -a overrides -c\n");
optc = 0;
}
return (0);
}
int
benchmark_initrun()
{
(void) setfdlimit(3 * lm_optB * lm_optT + 10);
return (0);
}
int
benchmark_initbatch_once(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i, j;
int errors = 0;
ts->ts_lsns = (int *)malloc(lm_optB * sizeof (int));
if (ts->ts_lsns == NULL) {
errors ++;
}
ts->ts_accs = (int *)malloc(lm_optB * sizeof (int));
if (ts->ts_accs == NULL) {
errors ++;
}
ts->ts_cons = (int *)malloc(lm_optB * sizeof (int));
if (ts->ts_cons == NULL) {
errors ++;
}
ts->ts_adds =
(struct sockaddr_in *)malloc(lm_optB *
sizeof (struct sockaddr_in));
if (ts->ts_accs == NULL) {
errors ++;
}
j = FIRSTPORT;
for (i = 0; i < lm_optB; i++) {
ts->ts_lsns[i] = socket(AF_INET, SOCK_STREAM, 0);
if (ts->ts_lsns[i] == -1) {
perror("socket");
errors ++;
}
/*
* make accept socket non-blocking so in case of errors
* we don't hang
*/
if (fcntl(ts->ts_lsns[i], F_SETFL, O_NDELAY) == -1) {
perror("fcntl");
errors ++;
}
if ((host = gethostbyname("localhost")) == NULL) {
errors ++;
}
for (;;) {
(void) memset(&ts->ts_adds[i], 0,
sizeof (struct sockaddr_in));
ts->ts_adds[i].sin_family = AF_INET;
ts->ts_adds[i].sin_port = htons(j++);
(void) memcpy(&ts->ts_adds[i].sin_addr.s_addr,
host->h_addr_list[0], sizeof (struct in_addr));
if (bind(ts->ts_lsns[i],
(struct sockaddr *)&ts->ts_adds[i],
sizeof (struct sockaddr_in)) == 0) {
break;
}
if (errno != EADDRINUSE) {
errors ++;
}
}
if (listen(ts->ts_lsns[i], 5) == -1) {
perror("listen");
errors ++;
}
}
return (errors);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int errors = 0;
int result;
if (ts->ts_once++ == 0) {
if (errors += benchmark_initbatch_once(tsd) == -1) {
return (-1);
}
}
for (i = 0; i < lm_optB; i++) {
ts->ts_cons[i] = socket(AF_INET, SOCK_STREAM, 0);
if (ts->ts_cons[i] == -1) {
perror("init:socket");
errors ++;
}
if (fcntl(ts->ts_cons[i], F_SETFL, O_NDELAY) == -1) {
perror("init:fcntl");
errors ++;
}
if (opta) {
result = connect(ts->ts_cons[i],
(struct sockaddr *)&ts->ts_adds[i],
sizeof (struct sockaddr_in));
if ((result == -1) && (errno != EINPROGRESS)) {
perror("init:connect");
errors ++;
}
}
}
return (errors);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int result;
struct sockaddr_in addr;
socklen_t size;
for (i = 0; i < lm_optB; i++) {
if (!opta) {
again:
result = connect(ts->ts_cons[i],
(struct sockaddr *)&ts->ts_adds[i],
sizeof (struct sockaddr_in));
if (result != 0 && errno != EISCONN) {
if (errno == EINPROGRESS) {
struct pollfd pollfd;
if (optc)
continue;
pollfd.fd = ts->ts_cons[i];
pollfd.events = POLLOUT;
if (poll(&pollfd, 1, -1) == 1)
goto again;
}
res->re_errors ++;
perror("benchmark:connect");
continue;
}
}
if (!optc) {
size = sizeof (struct sockaddr);
for (;;) {
struct pollfd pollfd;
result = accept(ts->ts_lsns[i],
(struct sockaddr *)&addr, &size);
if (result > 0 || (result == -1 &&
errno != EAGAIN))
break;
pollfd.fd = ts->ts_lsns[i];
pollfd.events = POLLIN;
if (poll(&pollfd, 1, -1) != 1)
break;
}
ts->ts_accs[i] = result;
if (result == -1) {
res->re_errors ++;
perror("benchmark:accept");
continue;
}
}
}
res->re_count = i;
return (0);
}
int
benchmark_finibatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++) {
if (!optc) {
(void) close(ts->ts_accs[i]);
}
(void) close(ts->ts_cons[i]);
}
return (0);
}

View File

@ -1,139 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* time dup
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include "libmicro.h"
#define DEFF "/dev/null"
static char *optf = DEFF;
static int fd;
typedef struct {
int ts_once;
int *ts_fds;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
lm_defB = 256;
(void) sprintf(lm_optstr, "f:");
(void) sprintf(lm_usage,
" [-f file-to-dup (default %s)]\n"
"notes: measures dup()\n",
DEFF);
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'f':
optf = optarg;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
(void) setfdlimit(lm_optB * lm_optT + 10);
fd = (open(optf, O_RDONLY));
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int errors = 0;
if (ts->ts_once++ == 0) {
ts->ts_fds = (int *)malloc(lm_optB * sizeof (int));
if (ts->ts_fds == NULL) {
errors ++;
}
for (i = 0; i < lm_optB; i++) {
ts->ts_fds[i] = -1;
}
}
return (errors);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++) {
ts->ts_fds[i] = dup(fd);
if (ts->ts_fds[i] == -1) {
res->re_errors++;
}
}
res->re_count = i;
return (0);
}
int
benchmark_finibatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++) {
(void) close(ts->ts_fds[i]);
}
return (0);
}

View File

@ -1,59 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* empty benchmark program to substitute for benchmarks
* that don't work/exist on some platforms
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*ARGSUSED*/
int
main(int argc, char *argv[])
{
char *tmp = strrchr(argv[0], '/');
if (tmp == NULL)
tmp = argv[0];
else
tmp++;
(void) printf(
"#\n"
"# benchmark %s not compiled/supported on this platform\n"
"#\n",
tmp);
return (0);
}

View File

@ -1,101 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* exec benchmark
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include "libmicro.h"
static char exec_path[1024];
static char *argv[3];
int
benchmark_init()
{
lm_defB = 128;
lm_tsdsize = 0;
(void) sprintf(lm_usage,
"notes: measures execv time of simple process()\n");
return (0);
}
/*ARGSUSED*/
int
benchmark_initbatch(void *tsd)
{
char buffer[80];
(void) strcpy(exec_path, lm_procpath);
(void) strcat(exec_path, "/exec_bin");
(void) sprintf(buffer, "%d", lm_optB);
argv[0] = exec_path;
argv[1] = strdup(buffer);
argv[2] = NULL;
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int c;
int status;
switch (c = fork()) {
case -1:
res->re_errors++;
break;
default:
if (waitpid(c, &status, 0) < 0)
res->re_errors++;
if (WIFEXITED(status) && WEXITSTATUS(status) != 0)
res->re_errors++;
break;
case 0:
if (execv(exec_path, argv) < 0)
res->re_errors++;
}
res->re_count = lm_optB;
return (0);
}

View File

@ -1,65 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* time program to recursively test exec time
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main(int argc, char *argv[])
{
int left;
if (argc == 1) {
exit(1);
}
left = atoi(argv[1]);
left--;
if (left <= 0) {
exit(0);
} else {
char buffer[80];
(void) sprintf(buffer, "%d", left);
argv[1] = buffer;
if (execv(argv[0], argv)) {
exit(2);
}
}
return (0);
}

View File

@ -1,160 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* benchmark exit
*/
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include "libmicro.h"
typedef struct {
int ts_once;
int *ts_pids;
} tsd_t;
static int opte = 0;
static barrier_t *b;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "e");
(void) sprintf(lm_usage,
" [-e] (uses _exit() rather than exit())"
"notes: measures exit()\n");
return (0);
}
/*ARGSUSED*/
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'e':
opte = 1;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
b = barrier_create(lm_optP * lm_optT * (lm_optB + 1), 0);
return (0);
}
int
benchmark_finirun()
{
(void) barrier_destroy(b);
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int errors = 0;
if (ts->ts_once++ == 0) {
ts->ts_pids = (int *)malloc(lm_optB * sizeof (pid_t));
if (ts->ts_pids == NULL) {
errors ++;
}
}
/*
* create processes to exit
*/
for (i = 0; i < lm_optB; i++) {
ts->ts_pids[i] = fork();
switch (ts->ts_pids[i]) {
case 0:
(void) barrier_queue(b, NULL);
if (opte)
_exit(0);
exit(0);
break;
case -1:
errors ++;
break;
default:
continue;
}
}
return (errors);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
/*
* start them all exiting
*/
(void) barrier_queue(b, NULL);
/*
* wait for them all to exit
*/
for (i = 0; i < lm_optB; i++) {
switch (waitpid((pid_t)-1, NULL, 0)) {
case 0:
continue;
case -1:
res->re_errors++;
}
}
res->re_count = i;
return (0);
}

View File

@ -1,73 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* test exp performance (should add range check)
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "libmicro.h"
int
benchmark_init()
{
(void) sprintf(lm_usage, "note: measures exp()");
lm_nsecs_per_op = 25;
lm_tsdsize = 0;
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
for (i = 0; i < lm_optB; i += 10) {
double value = 1.0 / (i + .01);
(void) exp(value);
(void) exp(value);
(void) exp(value);
(void) exp(value);
(void) exp(value);
(void) exp(value);
(void) exp(value);
(void) exp(value);
(void) exp(value);
(void) exp(value);
}
res->re_count = i;
return (0);
}

View File

@ -1,99 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* benchmark fcntl getfl
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include "libmicro.h"
#define DEFF "/dev/null"
static char *optf = DEFF;
static int fd = -1;
int
benchmark_init()
{
(void) sprintf(lm_optstr, "f:");
lm_tsdsize = 0;
(void) sprintf(lm_usage,
" [-f file-to-fcntl (default %s)]\n"
"notes: measures fcntl()\n",
DEFF);
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'f':
optf = optarg;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
if ((fd = open(optf, O_RDONLY)) == -1) {
perror("open");
exit(1);
}
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
int flags;
for (i = 0; i < lm_optB; i++) {
if (fcntl(fd, F_GETFL, &flags) == -1)
res->re_errors++;
}
res->re_count = i;
return (0);
}

View File

@ -1,100 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* measures O_NDELAY on socket
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include "libmicro.h"
static int fd = -1;
int
benchmark_init()
{
(void) sprintf(lm_usage,
"notes: measures F_GETFL/F_SETFL O_NDELAY on socket\n");
lm_tsdsize = 0;
return (0);
}
int
benchmark_initrun()
{
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd == -1) {
perror("socket");
exit(1);
}
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
int flags;
for (i = 0; i < lm_optB; i += 4) {
if (fcntl(fd, F_GETFL, &flags) < 0)
res->re_errors++;
flags |= O_NDELAY;
if (fcntl(fd, F_SETFL, &flags) < 0)
res->re_errors++;
if (fcntl(fd, F_GETFL, &flags) < 0)
res->re_errors++;
flags &= ~O_NDELAY;
if (fcntl(fd, F_SETFL, &flags) < 0)
res->re_errors++;
}
res->re_count = i;
return (0);
}

View File

@ -1,106 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* test file locking
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include "libmicro.h"
static int file;
int
block(int index)
{
struct flock fl;
fl.l_type = F_WRLCK;
fl.l_whence = SEEK_SET;
fl.l_start = index;
fl.l_len = 1;
return (fcntl(file, F_SETLKW, &fl) == -1);
}
int
unblock(int index)
{
struct flock fl;
fl.l_type = F_UNLCK;
fl.l_whence = SEEK_SET;
fl.l_start = index;
fl.l_len = 1;
return (fcntl(file, F_SETLK, &fl) == -1);
}
int
benchmark_init()
{
char fname[80];
int errors = 0;
(void) sprintf(fname, "/tmp/oneflock.%ld", getpid());
file = open(fname, O_CREAT | O_TRUNC | O_RDWR, 0600);
if (file == -1) {
errors++;
}
if (unlink(fname)) {
errors++;
}
lm_tsdsize = 0;
return (errors);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
int e = 0;
for (i = 0; i < lm_optB; i ++) {
e += block(0);
e += unblock(0);
}
res->re_count = i;
res->re_errors = e;
return (0);
}

View File

@ -1,131 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* benchmark fork
*/
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include "libmicro.h"
static barrier_t *b;
typedef struct {
int ts_once;
int *ts_pids;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_usage, "notes: measures fork()\n");
return (0);
}
int
benchmark_initrun()
{
b = barrier_create(lm_optP * lm_optT * (lm_optB + 1), 0);
return (0);
}
int
benchmark_finirun()
{
(void) barrier_destroy(b);
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int errors = 0;
if (ts->ts_once++ == 0) {
ts->ts_pids = (int *)malloc(lm_optB * sizeof (pid_t));
if (ts->ts_pids == NULL) {
errors++;
}
}
return (errors);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++) {
ts->ts_pids[i] = fork();
switch (ts->ts_pids[i]) {
case 0:
(void) barrier_queue(b, NULL);
exit(0);
break;
case -1:
res->re_errors++;
break;
default:
continue;
}
}
res->re_count = lm_optB;
(void) barrier_queue(b, NULL);
return (0);
}
int
benchmark_finibatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++) {
if (ts->ts_pids[i] > 0) {
(void) waitpid(ts->ts_pids[i], NULL, 0);
}
}
return (0);
}

View File

@ -1,74 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* getcontext
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ucontext.h>
#include "libmicro.h"
int
benchmark_init()
{
(void) sprintf(lm_usage, "notes: measures getcontext()\n");
lm_tsdsize = 0;
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
for (i = 0; i < lm_optB; i += 10) {
ucontext_t uc;
(void) getcontext(&uc);
(void) getcontext(&uc);
(void) getcontext(&uc);
(void) getcontext(&uc);
(void) getcontext(&uc);
(void) getcontext(&uc);
(void) getcontext(&uc);
(void) getcontext(&uc);
(void) getcontext(&uc);
(void) getcontext(&uc);
}
res->re_count = i;
return (0);
}

View File

@ -1,126 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* test getenv
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <string.h>
#include "libmicro.h"
#define DEFS 100
static int opts = DEFS;
int
benchmark_init()
{
(void) sprintf(lm_optstr, "s:");
lm_tsdsize = 0;
(void) sprintf(lm_usage,
" [-s search-size (default = %d)]\n"
"notes: measures time to search env for missing string\n",
DEFS);
lm_nsecs_per_op = 200;
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 's':
opts = atoi(optarg);
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
extern char ** environ;
int i, j;
/* count environment strings */
for (i = 0; environ[i++]; )
;
/*
* pad to desired count
*/
if (opts < i)
opts = i;
for (j = i; j < opts; j++) {
char buf[80];
(void) sprintf(buf, "VAR_%d=%d", j, j);
(void) putenv(strdup(buf));
}
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
char *search = "RUMPLSTILTSKIN";
for (i = 0; i < lm_optB; i += 10) {
(void) getenv(search);
(void) getenv(search);
(void) getenv(search);
(void) getenv(search);
(void) getenv(search);
(void) getenv(search);
(void) getenv(search);
(void) getenv(search);
(void) getenv(search);
(void) getenv(search);
}
res->re_count = i;
return (0);
}

View File

@ -1,163 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* getpeername test
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include "libmicro.h"
#define FIRSTPORT 12345
static int sock = -1;
int
benchmark_init()
{
(void) sprintf(lm_usage, "notes: measures getpeername()\n");
lm_tsdsize = 0;
return (0);
}
int
benchmark_initrun()
{
int j;
int opt = 1;
int result;
socklen_t size;
struct hostent *host;
struct sockaddr_in adds;
int sock2, sock3;
sock2 = socket(AF_INET, SOCK_STREAM, 0);
if (sock2 == -1) {
perror("socket");
exit(1);
}
if (setsockopt(sock2, SOL_SOCKET, SO_REUSEADDR,
&opt, sizeof (int)) == -1) {
perror("setsockopt");
exit(1);
}
if ((host = gethostbyname("localhost")) == NULL) {
perror("gethostbyname");
exit(1);
}
j = FIRSTPORT;
for (;;) {
(void) memset(&adds, 0, sizeof (struct sockaddr_in));
adds.sin_family = AF_INET;
adds.sin_port = htons(j++);
(void) memcpy(&adds.sin_addr.s_addr, host->h_addr_list[0],
sizeof (struct in_addr));
if (bind(sock2, (struct sockaddr *)&adds,
sizeof (struct sockaddr_in)) == 0) {
break;
}
if (errno != EADDRINUSE) {
perror("bind");
exit(1);
}
}
if (listen(sock2, 5) == -1) {
perror("listen");
exit(1);
}
sock3 = socket(AF_INET, SOCK_STREAM, 0);
if (sock3 == -1) {
perror("socket");
exit(1);
}
if (fcntl(sock3, F_SETFL, O_NDELAY) == -1) {
perror("fcntl");
exit(1);
}
result = connect(sock3, (struct sockaddr *)&adds,
sizeof (struct sockaddr_in));
if ((result == -1) && (errno != EINPROGRESS)) {
perror("connect");
exit(1);
}
size = sizeof (struct sockaddr);
sock = accept(sock2, (struct sockaddr *)&adds, &size);
if (sock == -1) {
perror("accept");
exit(1);
}
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
struct sockaddr_in adds;
socklen_t size;
for (i = 0; i < lm_optB; i++) {
size = sizeof (struct sockaddr_in);
if (getpeername(sock, (struct sockaddr *)&adds, &size) == -1) {
perror("getpeername");
exit(1);
res->re_errors++;
}
}
res->re_count = i;
return (0);
}

View File

@ -1,64 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* getpid
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "libmicro.h"
int
benchmark_init()
{
(void) sprintf(lm_usage, "note: measures getpid()");
lm_tsdsize = 0;
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
for (i = 0; i < lm_optB; i ++) {
(void) getpid();
}
res->re_count = i;
return (0);
}

View File

@ -1,73 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* getrusage
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/resource.h>
#include "libmicro.h"
int
benchmark_init()
{
(void) sprintf(lm_usage, "notes: measures getrusage(RUSAGE_SELF)\n");
lm_tsdsize = 0;
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
struct rusage u;
for (i = 0; i < lm_optB; i += 10) {
(void) getrusage(RUSAGE_SELF, &u);
(void) getrusage(RUSAGE_SELF, &u);
(void) getrusage(RUSAGE_SELF, &u);
(void) getrusage(RUSAGE_SELF, &u);
(void) getrusage(RUSAGE_SELF, &u);
(void) getrusage(RUSAGE_SELF, &u);
(void) getrusage(RUSAGE_SELF, &u);
(void) getrusage(RUSAGE_SELF, &u);
(void) getrusage(RUSAGE_SELF, &u);
(void) getrusage(RUSAGE_SELF, &u);
}
res->re_count = i;
return (0);
}

View File

@ -1,125 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* getsockname
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include "libmicro.h"
#define FIRSTPORT 12345
static struct sockaddr_in adds;
static int sock = -1;
int
benchmark_init()
{
(void) sprintf(lm_usage, "notes: measures getsockname()()\n");
lm_tsdsize = 0;
return (0);
}
int
benchmark_initrun()
{
int j;
int opt = 1;
struct hostent *host;
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock == -1) {
perror("socket");
exit(1);
}
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
&opt, sizeof (int)) == -1) {
perror("setsockopt");
exit(1);
}
if ((host = gethostbyname("localhost")) == NULL) {
perror("gethostbyname");
exit(1);
}
j = FIRSTPORT;
for (;;) {
(void) memset(&adds, 0, sizeof (struct sockaddr_in));
adds.sin_family = AF_INET;
adds.sin_port = htons(j++);
(void) memcpy(&adds.sin_addr.s_addr, host->h_addr_list[0],
sizeof (struct in_addr));
if (bind(sock, (struct sockaddr *)&adds,
sizeof (struct sockaddr_in)) == 0) {
break;
}
if (errno != EADDRINUSE) {
perror("bind");
exit(1);
}
}
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
struct sockaddr_in adds;
socklen_t size;
for (i = 0; i < lm_optB; i++) {
size = sizeof (struct sockaddr_in);
if (getsockname(sock, (struct sockaddr *)&adds, &size) == -1)
res->re_errors++;
}
res->re_count = i;
return (0);
}

View File

@ -1,72 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* gettimeofday test
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include "libmicro.h"
int
benchmark_init()
{
(void) sprintf(lm_usage, "note: measures gettimeofday()");
lm_tsdsize = 0;
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
struct timeval t;
for (i = 0; i < lm_optB; i += 10) {
(void) gettimeofday(&t, NULL);
(void) gettimeofday(&t, NULL);
(void) gettimeofday(&t, NULL);
(void) gettimeofday(&t, NULL);
(void) gettimeofday(&t, NULL);
(void) gettimeofday(&t, NULL);
(void) gettimeofday(&t, NULL);
(void) gettimeofday(&t, NULL);
(void) gettimeofday(&t, NULL);
(void) gettimeofday(&t, NULL);
}
res->re_count = i;
return (0);
}

View File

@ -1,110 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* isatty test
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include "libmicro.h"
#define DEFF "/dev/tty"
static char *optf = DEFF;
static int optb = 0;
typedef struct {
int ts_fd;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "f:b");
(void) sprintf(lm_usage,
" [-f file-to-isatty (default %s)]\n"
" [-b] (try to isatty an unopened fd)\n"
"notes: measures isatty()",
DEFF);
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'f':
optf = optarg;
break;
case 'b':
optb = 1;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initworker(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
ts->ts_fd = ((optb == 0) ?
open(optf, O_RDONLY) : 1024);
if (ts->ts_fd == -1) {
return (1);
}
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++) {
if (isatty(ts->ts_fd) == -1) {
res->re_errors++;
}
}
res->re_count = i;
return (0);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,196 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef LIBMICRO_H
#define LIBMICRO_H
#include <pthread.h>
#define LIBMICRO_VERSION "0.4.0"
#define STRSIZE 1024
typedef struct {
long long re_count;
long long re_errors;
long long re_t0;
long long re_t1;
} result_t;
typedef struct {
double sum;
long long count;
} histo_t;
#define HISTOSIZE 32
#define DATASIZE 100000
/*
* stats we compute on data sets
*/
typedef struct stats {
double st_min;
double st_max;
double st_mean;
double st_median;
double st_stddev;
double st_stderr;
double st_99confidence;
double st_skew;
double st_kurtosis;
double st_timecorr; /* correlation with respect to time */
} stats_t;
/*
* Barrier stuff
*/
typedef struct {
int ba_hwm; /* barrier setpoint */
int ba_flag; /* benchmark while true */
long long ba_deadline; /* when to stop */
int ba_phase; /* number of time used */
int ba_waiters; /* how many are waiting */
#ifdef USE_SEMOP
int ba_semid;
#else
pthread_mutex_t ba_lock;
pthread_cond_t ba_cv;
#endif
long long ba_count; /* how many ops */
long long ba_errors; /* how many errors */
int ba_quant; /* how many quant errors */
int ba_batches; /* how many samples */
double ba_starttime; /* test time start */
double ba_endtime; /* test time end */
#ifdef NEVER
double ba_tmin; /* min time taken */
double ba_tmax; /* max time taken */
double ba_ctmax; /* max after outliers */
double ba_mean; /* average value */
double ba_median; /* median value */
double ba_rawmedian; /* raw median value */
double ba_stddev; /* standard deviation */
double ba_stderr; /* standard error */
double ba_skew; /* skew */
double ba_kurtosis; /* kurtosis */
#endif
stats_t ba_raw; /* raw stats */
stats_t ba_corrected; /* corrected stats */
int ba_outliers; /* outlier count */
long long ba_t0; /* first thread/proc */
long long ba_t1; /* time of last thread */
long long ba_count0;
long long ba_errors0;
int ba_datasize; /* possible #items data */
double ba_data[1]; /* start of data ararry */
} barrier_t;
/*
* Barrier interfaces
*/
barrier_t *barrier_create(int hwm, int datasize);
int barrier_destroy(barrier_t *bar);
int barrier_queue(barrier_t *bar, result_t *res);
/*
* Functions that can be provided by the user
*/
int benchmark(void *tsd, result_t *res);
int benchmark_init();
int benchmark_fini();
int benchmark_initrun();
int benchmark_finirun();
int benchmark_initworker();
int benchmark_finiworker();
int benchmark_initbatch(void *tsd);
int benchmark_finibatch(void *tsd);
int benchmark_optswitch(int opt, char *optarg);
char *benchmark_result();
/*
* Globals exported to the user
*/
extern int lm_argc;
extern char **lm_argv;
extern int lm_optB;
extern int lm_optD;
extern int lm_optH;
extern char *lm_optN;
extern int lm_optP;
extern int lm_optS;
extern int lm_optT;
extern int lm_defB;
extern int lm_defD;
extern int lm_defH;
extern char *lm_defN;
extern int lm_defP;
extern int lm_defS;
extern int lm_defT;
extern int lm_nsecs_per_op;
extern char *lm_procpath;
extern char lm_procname[STRSIZE];
extern char lm_usage[STRSIZE];
extern char lm_optstr[STRSIZE];
extern char lm_header[STRSIZE];
extern size_t lm_tsdsize;
/*
* Utility functions
*/
int getpindex();
int gettindex();
void *gettsd(int p, int t);
long long getusecs();
long long getnsecs();
int setfdlimit(int limit);
long long sizetoll();
int sizetoint();
int fit_line(double *, double *, int, double *, double *);
long long get_nsecs_resolution();
#endif /* LIBMICRO_H */

View File

@ -1,44 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Separate file for main so we can link other programs
* with libmicro
*/
#include <stdlib.h>
extern int actual_main(int, char **);
int
main(int argc, char *argv[])
{
return (actual_main(argc, argv));
}

View File

@ -1,127 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* listen benchmark
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include "libmicro.h"
#define FIRSTPORT 12345
static struct sockaddr_in adds;
static int sock = -1;
int
benchmark_init()
{
(void) sprintf(lm_usage, "notes: measures listen()()\n");
lm_tsdsize = 0;
return (0);
}
int
benchmark_initrun()
{
int j;
int opt = 1;
struct hostent *host;
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock == -1) {
perror("socket");
exit(1);
}
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
&opt, sizeof (int)) == -1) {
perror("setsockopt");
exit(1);
}
if ((host = gethostbyname("localhost")) == NULL) {
perror("gethostbyname");
exit(1);
}
j = FIRSTPORT;
for (;;) {
(void) memset(&adds, 0, sizeof (struct sockaddr_in));
adds.sin_family = AF_INET;
adds.sin_port = htons(j++);
(void) memcpy(&adds.sin_addr.s_addr, host->h_addr_list[0],
sizeof (struct in_addr));
if (bind(sock, (struct sockaddr *)&adds,
sizeof (struct sockaddr_in)) == 0) {
break;
}
if (errno != EADDRINUSE) {
perror("bind");
exit(1);
}
}
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
for (i = 0; i < lm_optB; i += 2) {
if (listen(sock, 4) == -1)
res->re_errors++;
if (listen(sock, 5) == -1)
res->re_errors++;
}
res->re_count = i;
return (0);
}

View File

@ -1,75 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* localtime benchmark
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "libmicro.h"
int
benchmark_init()
{
(void) sprintf(lm_usage, "notes: measures localtime_r()\n");
lm_tsdsize = 0;
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
struct tm tms;
static time_t clock1 = 0L;
static time_t clock2 = 1L;
for (i = 0; i < lm_optB; i += 10) {
(void) localtime_r(&clock1, &tms);
(void) localtime_r(&clock2, &tms);
(void) localtime_r(&clock1, &tms);
(void) localtime_r(&clock2, &tms);
(void) localtime_r(&clock1, &tms);
(void) localtime_r(&clock2, &tms);
(void) localtime_r(&clock1, &tms);
(void) localtime_r(&clock2, &tms);
(void) localtime_r(&clock1, &tms);
(void) localtime_r(&clock2, &tms);
}
res->re_count = i;
return (0);
}

View File

@ -1,73 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* log benchmark - should do wider range...
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "libmicro.h"
int
benchmark_init()
{
(void) sprintf(lm_usage, "note: measures log()");
lm_nsecs_per_op = 75;
lm_tsdsize = 0;
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
for (i = 0; i < lm_optB; i += 10) {
double value = i + .01;
(void) log(value);
(void) log(value);
(void) log(value);
(void) log(value);
(void) log(value);
(void) log(value);
(void) log(value);
(void) log(value);
(void) log(value);
(void) log(value);
}
res->re_count = i;
return (0);
}

View File

@ -1,65 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* benchmark longjmp
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#include "libmicro.h"
int
benchmark_init()
{
(void) sprintf(lm_usage, "notes: measures longjmp()\n");
lm_tsdsize = 0;
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i = 0;
jmp_buf env;
(void) setjmp(env);
i++;
if (i < lm_optB)
longjmp(env, 0);
res->re_count = i;
return (0);
}

View File

@ -1,71 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* lrand48
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "libmicro.h"
int
benchmark_init()
{
(void) sprintf(lm_usage, "note: measures lrand48()");
lm_nsecs_per_op = 10;
lm_tsdsize = 0;
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
for (i = 0; i < lm_optB; i += 10) {
(void) lrand48();
(void) lrand48();
(void) lrand48();
(void) lrand48();
(void) lrand48();
(void) lrand48();
(void) lrand48();
(void) lrand48();
(void) lrand48();
(void) lrand48();
}
res->re_count = i;
return (0);
}

View File

@ -1,130 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* lseek
*/
#ifdef linux
#define _XOPEN_SOURCE 500
#endif
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include "libmicro.h"
#define DEFF "/dev/zero"
#define DEFS 1024
static char *optf = DEFF;
static long long opts = DEFS;
typedef struct {
int ts_once;
int ts_fd;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "f:s:");
(void) sprintf(lm_usage,
" [-f file-to-read (default %s)]\n"
" [-s buffer-size (default %d)]\n"
"notes: measures lseek()\n",
DEFF, DEFS);
(void) sprintf(lm_header, "%8s", "size");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'f':
optf = optarg;
break;
case 's':
opts = sizetoll(optarg);
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
if (ts->ts_once++ == 0) {
ts->ts_fd = open(optf, O_RDONLY);
}
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i += 2) {
if (lseek(ts->ts_fd, 0L, SEEK_SET) != 0) {
res->re_errors++;
}
if (lseek(ts->ts_fd, opts, SEEK_SET) != opts) {
res->re_errors++;
}
}
res->re_count = i;
return (0);
}
char *
benchmark_result()
{
static char result[256];
(void) sprintf(result, "%8lld", opts);
return (result);
}

View File

@ -1,138 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* malloc benchmark (crude)
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include "libmicro.h"
static int optg = 100;
static int opts[32] = {32};
static int optscnt = 0;
typedef struct {
void **ts_glob;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "s:g:");
(void) sprintf(lm_usage,
" [-g number of mallocs before free (default %d)]\n"
" [-s size to malloc (default %d)."
" Up to 32 sizes accepted\n"
"notes: measures malloc()/free()",
optg, opts[0]);
(void) sprintf(lm_header, "%6s %6s", "glob", "sizes");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'g':
optg = sizetoint(optarg);
break;
case 's':
opts[optscnt] = sizetoint(optarg);
optscnt = ++optscnt & (31);
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initworker(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
if (optscnt == 0)
optscnt = 1;
ts->ts_glob = malloc(sizeof (void *)* optg);
if (ts->ts_glob == NULL) {
return (1);
}
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i, j, k;
for (i = 0; i < lm_optB; i++) {
for (k = j = 0; j < optg; j++) {
if ((ts->ts_glob[j] = malloc(opts[k++])) == NULL)
res->re_errors++;
if (k >= optscnt)
k = 0;
}
for (j = 0; j < optg; j++) {
free(ts->ts_glob[j]);
}
}
res->re_count = i * j;
return (0);
}
char *
benchmark_result()
{
static char result[256];
int i;
(void) sprintf(result, "%6d ", optg);
for (i = 0; i < optscnt; i++)
(void) sprintf(result + strlen(result), "%d ", opts[i]);
return (result);
}

View File

@ -1,160 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* memcpy
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "libmicro.h"
#define DEFS 8192
#define DEFR 1
static long long opts = DEFS;
static int optf;
static int optt;
static int opta;
typedef struct {
char *ts_src;
char *ts_dest;
int ts_srcsize;
int ts_destsize;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "a:s:ft");
(void) sprintf(lm_usage,
" [-s buffer-size (default %d)]\n"
" [-a relative alignment (default page aligned)]\n"
" [-f (rotate \"from\" buffer to keep it out of cache)]\n"
" [-t (rotate \"to\" buffer to keep it out of cache)]\n"
"notes: measures memcpy()\n",
DEFS);
(void) sprintf(lm_header, "%8s", "size");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'f':
optf++;
break;
case 't':
optt++;
break;
case 's':
opts = sizetoll(optarg);
break;
case 'a':
opta = sizetoint(optarg);
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initworker(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
if (optf)
ts->ts_srcsize = 64 * 1024 * 1024;
else
ts->ts_srcsize = opts + opta;
if (optt)
ts->ts_destsize = 64 * 1024 * 1024;
else
ts->ts_destsize = (int)opts;
ts->ts_src = opta + (char *)valloc(ts->ts_srcsize);
ts->ts_dest = valloc(ts->ts_destsize);
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
char *src = ts->ts_src;
char *dest = ts->ts_dest;
int bump = (int)opts;
if (bump < 1024)
bump = 1024; /* avoid prefetched area */
for (i = 0; i < lm_optB; i++) {
(void) memcpy(dest, src, opts);
if (optf) {
src += bump;
if (src + opts > ts->ts_src + ts->ts_srcsize)
src = ts->ts_src;
}
if (optt) {
dest += bump;
if (dest + opts > ts->ts_dest + ts->ts_destsize)
dest = ts->ts_dest;
}
}
res->re_count = i;
return (0);
}
char *
benchmark_result()
{
static char result[256];
(void) sprintf(result, "%8lld", opts);
return (result);
}

View File

@ -1,160 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* memmove
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "libmicro.h"
#define DEFS 8192
#define DEFR 1
static long long opts = DEFS;
static int optf;
static int optt;
static int opta;
typedef struct {
char *ts_src;
char *ts_dest;
int ts_srcsize;
int ts_destsize;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "a:s:ft");
(void) sprintf(lm_usage,
" [-s buffer-size (default %d)]\n"
" [-a relative alignment (default page aligned)]\n"
" [-f (rotate \"from\" buffer to keep it out of cache)]\n"
" [-t (rotate \"to\" buffer to keep it out of cache)]\n"
"notes: measures memmove()\n",
DEFS);
(void) sprintf(lm_header, "%8s", "size");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'f':
optf++;
break;
case 't':
optt++;
break;
case 's':
opts = sizetoll(optarg);
break;
case 'a':
opta = sizetoint(optarg);
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initworker(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
if (optf)
ts->ts_srcsize = 64 * 1024 * 1024;
else
ts->ts_srcsize = opts + opta;
if (optt)
ts->ts_destsize = 64 * 1024 * 1024;
else
ts->ts_destsize = (int)opts;
ts->ts_src = opta + (char *)valloc(ts->ts_srcsize);
ts->ts_dest = valloc(ts->ts_destsize);
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
char *src = ts->ts_src;
char *dest = ts->ts_dest;
int bump = (int)opts;
if (bump < 1024)
bump = 1024; /* avoid prefetched area */
for (i = 0; i < lm_optB; i++) {
(void) memmove(dest, src, opts);
if (optf) {
src += bump;
if (src + opts > ts->ts_src + ts->ts_srcsize)
src = ts->ts_src;
}
if (optt) {
dest += bump;
if (dest + opts > ts->ts_dest + ts->ts_destsize)
dest = ts->ts_dest;
}
}
res->re_count = i;
return (0);
}
char *
benchmark_result()
{
static char result[256];
(void) sprintf(result, "%8lld", opts);
return (result);
}

View File

@ -1,146 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* memory access time check
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <string.h>
#include "libmicro.h"
static long opts = 1024*1024;
typedef struct {
long **ts_data;
long ts_result;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "s:");
(void) sprintf(lm_usage,
" [-s size] number of bytes to "
" access (default %ld)\n"
"notes: measures \"random\" memory access times\n",
opts);
(void) sprintf(lm_header, "%8s", "size");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 's':
opts = sizetoint(optarg);
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initworker(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i, j;
ts->ts_data = malloc(opts);
if (ts->ts_data == NULL) {
return (1);
}
/*
* use lmbench style backwards stride
*/
for (i = 0; i < opts / sizeof (long); i++) {
j = i - 128;
if (j < 0)
j = j + opts / sizeof (long);
ts->ts_data[i] = (long *)&(ts->ts_data[j]);
}
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
long **ptr = ts->ts_data;
for (i = 0; i < lm_optB; i += 10) {
ptr = (long **)*ptr;
ptr = (long **)*ptr;
ptr = (long **)*ptr;
ptr = (long **)*ptr;
ptr = (long **)*ptr;
ptr = (long **)*ptr;
ptr = (long **)*ptr;
ptr = (long **)*ptr;
ptr = (long **)*ptr;
ptr = (long **)*ptr;
}
ts->ts_result = (long)*ptr;
res->re_count = lm_optB;
return (0);
}
char *
benchmark_result()
{
static char result[256];
(void) sprintf(result, "%8ld ", opts);
return (result);
}

View File

@ -1,169 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* memset
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "libmicro.h"
#define DEFS 8192
static long long opts = DEFS;
static int opta = 0;
static int optu = 0;
static char *optas = "4k";
typedef struct {
char *ts_buff;
int ts_size;
int ts_offset;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "a:us:");
(void) sprintf(lm_usage,
" [-s buffer-size (default %d)]\n"
" [-a alignment (force buffer alignment)]\n"
" [-u (try to always use uncached memory)]"
"notes: measures memset()\n",
DEFS);
(void) sprintf(lm_header, "%8s%16s", "size", "alignment");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'u':
optu = 1;
break;
case 's':
opts = sizetoll(optarg);
break;
case 'a':
opta = sizetoll(optarg);
if (opta > 4096)
opta = 0;
else
optas = optarg;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initworker(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int errors = 0;
int i;
if (optu) {
ts->ts_size = 1024 * 1024 * 64;
ts->ts_offset = opta;
} else {
ts->ts_size = opta + opts;
ts->ts_offset = opta;
}
if ((ts->ts_buff = (char *)valloc(ts->ts_size)) == NULL)
errors++;
for (i = 0; i < ts->ts_size; i++)
ts->ts_buff[i] = 0;
return (errors);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
tsd_t *ts = (tsd_t *)tsd;
if (optu) {
char *buf = ts->ts_buff + ts->ts_offset;
char *end = ts->ts_buff + ts->ts_size;
int offset = ts->ts_offset;
for (i = 0; i < lm_optB; i ++) {
(void) memset(buf, 0, opts);
buf = (char *)(((unsigned long)buf + opts + 4095) &
~4095) + offset;
if (buf + opts > end)
buf = ts->ts_buff + offset;
}
} else {
char *buf = ts->ts_buff + ts->ts_offset;
for (i = 0; i < lm_optB; i += 10) {
(void) memset(buf, 0, opts);
(void) memset(buf, 0, opts);
(void) memset(buf, 0, opts);
(void) memset(buf, 0, opts);
(void) memset(buf, 0, opts);
(void) memset(buf, 0, opts);
(void) memset(buf, 0, opts);
(void) memset(buf, 0, opts);
(void) memset(buf, 0, opts);
(void) memset(buf, 0, opts);
}
}
res->re_count = i;
return (0);
}
char *
benchmark_result()
{
static char result[256];
(void) sprintf(result, "%8lld%12s", opts, optas);
return (result);
}

View File

@ -1,28 +0,0 @@
#!/bin/sh -x
#
# Copyright 2003 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# script to make tarball... args are contents to be inserted
#
libmicro_version=`bin/getpid -V`
case $libmicro_version in
[0-9]*)
;;
*)
echo "ERROR: cannot determine libMicro version"
exit 1
esac
dirname="libMicro-$libmicro_version"
here=`pwd`
target=$here/libMicro.tar
tmpdir=/tmp/libmicro.$$
mkdir -p $tmpdir/$dirname
cp $* $tmpdir/$dirname
cd $tmpdir
tar cvf $target $dirname
cd $here
rm -rf $tmpdir

View File

@ -1,112 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* mktime
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "libmicro.h"
typedef struct {
struct tm ts_tm1;
struct tm ts_tm2;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_usage,
"notes: measures mktime()\n");
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
time_t clock1;
time_t clock2;
clock1 = time(NULL);
clock2 = clock1 + 1;
(void) localtime_r(&clock1, &ts->ts_tm1);
(void) localtime_r(&clock2, &ts->ts_tm2);
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
int i;
tsd_t *ts = (tsd_t *)tsd;
struct tm t1, t2;
for (i = 0; i < lm_optB; i += 10) {
t1 = ts->ts_tm1;
t2 = ts->ts_tm2;
(void) mktime(&t1);
(void) mktime(&t2);
t1 = ts->ts_tm1;
t2 = ts->ts_tm2;
(void) mktime(&t1);
(void) mktime(&t2);
t1 = ts->ts_tm1;
t2 = ts->ts_tm2;
(void) mktime(&t1);
(void) mktime(&t2);
t1 = ts->ts_tm1;
t2 = ts->ts_tm2;
(void) mktime(&t1);
(void) mktime(&t2);
t1 = ts->ts_tm1;
t2 = ts->ts_tm2;
(void) mktime(&t1);
(void) mktime(&t2);
}
res->re_count = lm_optB;
return (0);
}

View File

@ -1,198 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/mman.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <strings.h>
#include "libmicro.h"
typedef volatile char vchar_t;
typedef struct {
int ts_once;
vchar_t ** ts_map;
vchar_t ts_foo;
} tsd_t;
#define DEFF "/dev/zero"
#define DEFL 8192
static char *optf = DEFF;
static long long optl = DEFL;
static int optr = 0;
static int opts = 0;
static int optw = 0;
static int fd = -1;
static int anon = 0;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "f:l:rsw");
(void) sprintf(lm_usage,
" [-f file-to-map (default %s)]\n"
" [-l mapping-length (default %d)]\n"
" [-r] (read a byte from each page)\n"
" [-w] (write a byte on each page)\n"
" [-s] (use MAP_SHARED)\n"
"notes: measures mmap()\n",
DEFF, DEFL);
(void) sprintf(lm_header, "%8s %5s", "length", "flags");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'f':
optf = optarg;
anon = strcmp(optf, "MAP_ANON") == 0;
break;
case 'l':
optl = sizetoll(optarg);
break;
case 'r':
optr = 1;
break;
case 's':
opts = 1;
break;
case 'w':
optw = 1;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
if (!anon)
fd = open(optf, O_RDWR);
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int errors = 0;
if (ts->ts_once++ == 0) {
ts->ts_map = (vchar_t **)malloc(lm_optB * sizeof (void *));
if (ts->ts_map == NULL) {
errors++;
}
}
return (errors);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i, j;
for (i = 0; i < lm_optB; i++) {
if (anon) {
ts->ts_map[i] = (vchar_t *)mmap(NULL, optl,
PROT_READ | PROT_WRITE,
MAP_ANON | (opts ? MAP_SHARED : MAP_PRIVATE),
-1, 0L);
} else {
ts->ts_map[i] = (vchar_t *)mmap(NULL, optl,
PROT_READ | PROT_WRITE,
opts ? MAP_SHARED : MAP_PRIVATE,
fd, 0L);
}
if (ts->ts_map[i] == MAP_FAILED) {
res->re_errors++;
continue;
}
if (optr) {
for (j = 0; j < optl; j += 4096) {
ts->ts_foo += ts->ts_map[i][j];
}
}
if (optw) {
for (j = 0; j < optl; j += 4096) {
ts->ts_map[i][j] = 1;
}
}
}
res->re_count = i;
return (0);
}
int
benchmark_finibatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++) {
(void) munmap((void *)ts->ts_map[i], optl);
}
return (0);
}
char *
benchmark_result()
{
static char result[256];
char flags[5];
flags[0] = anon ? 'a' : '-';
flags[1] = optr ? 'r' : '-';
flags[2] = optw ? 'w' : '-';
flags[3] = opts ? 's' : '-';
flags[4] = 0;
(void) sprintf(result, "%8lld %5s", optl, flags);
return (result);
}

View File

@ -1,200 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <strings.h>
#include "libmicro.h"
typedef volatile char vchar_t;
typedef struct {
int ts_batch;
int ts_res;
} tsd_t;
#define DEFF "/dev/zero"
#define DEFL 8192
static char *optf = DEFF;
static long long optl = DEFL;
static int optr = 0;
static int optw = 0;
static int opts = 0;
static int optt = 0;
static int fd = -1;
static int anon = 0;
static int foo = 0;
static vchar_t *seg;
static int pagesize;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "f:l:rstw");
(void) sprintf(lm_usage,
" [-f file-to-map (default %s)]\n"
" [-l mapping-length (default %d)]\n"
" [-r] (read a byte from each page)\n"
" [-w] (write a byte on each page)\n"
" [-s] (use MAP_SHARED)\n"
" [-t] (touch each page after restoring permissions)\n"
"notes: measures mprotect()\n",
DEFF, DEFL);
(void) sprintf(lm_header, "%8s %5s", "size", "flags");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'f':
optf = optarg;
anon = strcmp(optf, "MAP_ANON") == 0;
break;
case 'l':
optl = sizetoll(optarg);
break;
case 'r':
optr = 1;
break;
case 's':
opts = 1;
break;
case 't':
optt = 1;
break;
case 'w':
optw = 1;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
int flags;
int i;
if (!anon)
fd = open(optf, O_RDWR);
flags = opts ? MAP_SHARED : MAP_PRIVATE;
flags |= anon ? MAP_ANON : 0;
seg = (vchar_t *)mmap(NULL, lm_optB * optl, PROT_READ | PROT_WRITE,
flags, anon ? -1 : fd, 0L);
if (seg == MAP_FAILED) {
return (-1);
}
if (optr) {
for (i = 0; i < lm_optB * optl; i += 4096) {
foo += seg[i];
}
}
if (optw) {
for (i = 0; i < lm_optB * optl; i += 4096) {
seg[i] = 1;
}
}
pagesize = getpagesize();
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int us;
int prot = PROT_NONE;
int j, k;
us = (getpindex() * lm_optT) + gettindex();
for (i = 0; i < lm_optB; i++) {
switch ((us + ts->ts_batch + i) % 2) {
case 0:
prot = PROT_NONE;
if (optt) {
for (j = k = 0; j < optl; j += pagesize)
k += seg[i * optl + j];
ts->ts_res += k;
}
break;
default:
prot = PROT_READ | PROT_WRITE;
break;
}
if (mprotect((void *)&seg[i * optl], optl, prot) == -1) {
res->re_errors++;
}
}
res->re_count += lm_optB;
ts->ts_batch++;
return (0);
}
char *
benchmark_result()
{
static char result[256];
char flags[6];
flags[0] = anon ? 'a' : '-';
flags[1] = optr ? 'r' : '-';
flags[2] = optw ? 'w' : '-';
flags[3] = opts ? 's' : '-';
flags[4] = optt ? 't' : '-';
flags[5] = 0;
(void) sprintf(result, "%8lld %5s", optl, flags);
return (result);
}

View File

@ -1,190 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/mman.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <strings.h>
#include "libmicro.h"
typedef struct {
char *ts_map;
int ts_foo; /* defeat optimizers */
} tsd_t;
#define DEFF "/dev/zero"
#define DEFL 8192
static char *optf = DEFF;
static long long optl = DEFL;
static int optr = 0;
static int opts = 0;
static int optw = 0;
static int opta = MS_SYNC;
static int opti = 0;
static int anon = 0;
static int pagesize;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "af:il:rsw");
(void) sprintf(lm_usage,
" [-f file-to-map (default %s)]\n"
" [-l mapping-length (default %d)]\n"
" [-r] (read a byte from each page between msyncs)\n"
" [-w] (write a byte to each page between msyncs)\n"
" [-s] (use MAP_SHARED instead of MAP_PRIVATE)\n"
" [-a (specify MS_ASYNC rather than default MS_SYNC)\n"
" [-i (specify MS_INVALIDATE)\n"
"notes: measures msync()\n",
DEFF, DEFL);
(void) sprintf(lm_header, "%8s %6s", "length", "flags");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'a':
opta = MS_ASYNC;
break;
case 'f':
optf = optarg;
break;
case 'i':
opti = MS_INVALIDATE;
break;
case 'l':
optl = sizetoll(optarg);
break;
case 'r':
optr = 1;
break;
case 's':
opts = 1;
break;
case 'w':
optw = 1;
break;
default:
return (-1);
}
pagesize = getpagesize();
return (0);
}
int
benchmark_initworker(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int fd;
if ((fd = open(optf, O_RDWR)) < 0) {
perror("open:");
return (1);
}
(void) ftruncate(fd, optl);
if ((ts->ts_map = (char *)mmap(NULL, optl,
PROT_READ | PROT_WRITE, opts ? MAP_SHARED : MAP_PRIVATE,
fd, 0L)) == MAP_FAILED) {
perror("mmap:");
(void) close(fd);
return (1);
}
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i, j;
for (i = 0; i < lm_optB; i++) {
if (msync(ts->ts_map, optl, opta | opti) < 0) {
perror("msync:");
res->re_errors++;
break;
}
if (optr) {
for (j = 0; j < optl; j += pagesize) {
ts->ts_foo += ts->ts_map[j];
}
}
if (optw) {
for (j = 0; j < optl; j += pagesize) {
ts->ts_map[j] = 1;
}
}
}
res->re_count = i;
return (0);
}
char *
benchmark_result()
{
static char result[256];
char flags[6];
flags[0] = anon ? 'a' : '-';
flags[1] = optr ? 'r' : '-';
flags[2] = optw ? 'w' : '-';
flags[3] = opts ? 's' : '-';
flags[4] = opti ? 'i' : '-';
flags[5] = 0;
(void) sprintf(result, "%8lld %6s", optl, flags);
return (result);
}

View File

@ -1,201 +0,0 @@
#!/bin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms
# of the Common Development and Distribution License
# (the "License"). You may not use this file except
# in compliance with the License.
#
# You can obtain a copy of the license at
# src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing
# permissions and limitations under the License.
#
# When distributing Covered Code, include this CDDL
# HEADER in each file and include the License file at
# usr/src/OPENSOLARIS.LICENSE. If applicable,
# add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your
# own identifying information: Portions Copyright [yyyy]
# [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# output html comparison of several libmicro output data files
# usage: multiview file1 file2 file3 file4 ...
#
# relative ranking is calculated using first as reference
# color interpolation is done to indicate relative performance;
# the redder the color, the slower the result, the greener the
# faster
/bin/nawk ' BEGIN {
benchmark_count = 0;
header_count = 0;
}
/^#/ {
continue;
}
/errors/ {
continue;
}
/^\!/ {
split($0, A_header, ":");
name = substr(A_header[1],2);
headers[name]=name;
header_data[name,FILENAME] = substr($0, length(name) + 3);
if (header_names[name] == 0) {
header_names[name] = ++header_count;
headers[header_count] = name;
}
continue;
}
{
if(NF >= 7) {
if (benchmark_names[$1] == 0) {
benchmark_names[$1] = ++benchmark_count;
benchmarks[benchmark_count] = $1;
}
if ($6 == 0)
benchmark_data[$1,FILENAME] = $4;
else
benchmark_data[$1,FILENAME] = -1;
}
}
END {
printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n");
printf("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
printf("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
printf("<head>\n");
printf("<meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\" />\n");
printf("<meta name=\"author\" content=\"autogen\" />\n");
printf("<title>multiview comparison</title>\n")
printf("<style type=\"text/css\">\n");
printf("body { font-family: sans-serif; }\n");
printf("table { border-collapse: collapse; }\n");
printf("td { padding: 0.1em; border: 1px solid #ccc; text-align: right; }\n");
printf("td.header { text-align: left; }\n");
printf("pre { margin-top: 0em; margin-bottom: 0em; }\n");
printf("</style>\n");
printf("</head>\n");
printf("<body bgcolor=\"#ffffff\" link=\"#0000ee\" vlink=\"#cc0000\" alink=\"#0000ee\">\n");
printf("<table border=\"1\" cellspacing=\"1\">\n");
printf("<tbody>\n");
for(i = 1; i <= header_count; i++) {
hname = headers[i];
printf("<tr><td class=\"header\">%s</td>\n", hname);
for (j = 1; j < ARGC; j++) {
sub("^[\t ]+", "", header_data[hname, ARGV[j]]);
printf("<td class=\"header\">%s</td>\n", header_data[hname, ARGV[j]]);
}
printf("</tr>\n");
}
printf("<tr>\n");
printf("<th>BENCHMARK</th>\n");
printf("<th align=\"right\">USECS</th>\n");
for (i = 2; i < ARGC; i++)
printf("<th align=\"right\">USECS [percentage]</th>\n");
printf("</tr>\n");
for(i = 1; i < benchmark_count; i++) {
for(j = 1; j < benchmark_count; j++) {
if (benchmarks[j] > benchmarks[j + 1]) {
tmp = benchmarks[j];
benchmarks[j] = benchmarks[j+1];
benchmarks[j+1] = tmp;
}
}
}
for(i = 1; i <= benchmark_count; i++) {
name = benchmarks[i];
a = benchmark_data[name, ARGV[1]];
printf("<tr>\n");
printf("<td>%s</td>\n", name);
if (a > 0)
printf("<td><pre>%f</pre></td>\n", a);
else {
if (a < 0)
printf("<td bgcolor=\"#ff0000\">%s</td>\n", "ERRORS");
else
printf("<td>%s</td>\n", "missing");
for (j = 2; j < ARGC; j++)
printf("<td>%s</td>\n", "not computed");
continue;
}
for (j = 2; j < ARGC; j++) {
b = benchmark_data[name, ARGV[j]];
if (b > 0) {
factor = b/a;
bgcolor = colormap(factor);
if (factor > 1)
percentage = -(factor * 100 - 100);
if (factor <= 1)
percentage = 100/factor - 100;
printf("<td bgcolor=\"%s\"><pre>%11.5f[%#+7.1f%%]</pre></td>\n",
bgcolor, b, percentage);
}
else if (b < 0)
printf("<td bgcolor=\"#ff0000\">%s</td>\n", "ERRORS");
else
printf("<td>%25s</td>\n", "missing");
}
printf("</tr>\n");
}
printf("</tbody></table></body></html>\n");
}
function colormap(value, bgcolor, r, g, b)
{
if (value <= .2)
value = .2;
if (value > 5)
value = 5;
if (value < .9) {
r = colorcalc(.2, value, .9, 0, 255);
g = colorcalc(.2, value, .9, 153, 255);
b = colorcalc(.2, value, .9, 0, 255);
bgcolor=sprintf("#%2.2x%2.2x%2.2x", r, g, b);
}
else if (value < 1.1)
bgcolor="#ffffff";
else {
r = 255;
g = colorcalc(1.1, value, 5, 255, 0);
b = colorcalc(1.1, value, 5, 255, 0);
bgcolor=sprintf("#%2.2x%2.2x%2.2x", r, g, b);
}
return (bgcolor);
}
function colorcalc(min, value, max, mincolor, maxcolor)
{
return((value - min)/(max-min) * (maxcolor-mincolor) + mincolor);
}
' "$@"

View File

@ -1,201 +0,0 @@
#!/bin/sh
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms
# of the Common Development and Distribution License
# (the "License"). You may not use this file except
# in compliance with the License.
#
# You can obtain a copy of the license at
# src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing
# permissions and limitations under the License.
#
# When distributing Covered Code, include this CDDL
# HEADER in each file and include the License file at
# usr/src/OPENSOLARIS.LICENSE. If applicable,
# add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your
# own identifying information: Portions Copyright [yyyy]
# [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# output html comparison of several libmicro output data files
# usage: multiview file1 file2 file3 file4 ...
#
# relative ranking is calculated using first as reference
# color interpolation is done to indicate relative performance;
# the redder the color, the slower the result, the greener the
# faster
/bin/nawk ' BEGIN {
benchmark_count = 0;
header_count = 0;
}
/^#/ {
continue;
}
/errors/ {
continue;
}
/^\!/ {
split($0, A_header, ":");
name = substr(A_header[1],2);
headers[name]=name;
header_data[name,FILENAME] = substr($0, length(name) + 3);
if (header_names[name] == 0) {
header_names[name] = ++header_count;
headers[header_count] = name;
}
continue;
}
{
if(NF >= 7) {
if (benchmark_names[$1] == 0) {
benchmark_names[$1] = ++benchmark_count;
benchmarks[benchmark_count] = $1;
}
if ($6 == 0)
benchmark_data[$1,FILENAME] = $4;
else
benchmark_data[$1,FILENAME] = -1;
}
}
END {
printf("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n");
printf("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
printf("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
printf("<head>\n");
printf("<meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\" />\n");
printf("<meta name=\"author\" content=\"autogen\" />\n");
printf("<title>multiview comparison</title>\n")
printf("<style type=\"text/css\">\n");
printf("body { font-family: sans-serif; }\n");
printf("table { border-collapse: collapse; }\n");
printf("td { padding: 0.1em; border: 1px solid #ccc; text-align: right; }\n");
printf("td.header { text-align: left; }\n");
printf("pre { margin-top: 0em; margin-bottom: 0em; }\n");
printf("</style>\n");
printf("</head>\n");
printf("<body bgcolor=\"#ffffff\" link=\"#0000ee\" vlink=\"#cc0000\" alink=\"#0000ee\">\n");
printf("<table border=\"1\" cellspacing=\"1\">\n");
printf("<tbody>\n");
for(i = 1; i <= header_count; i++) {
hname = headers[i];
printf("<tr><td class=\"header\">%s</td>\n", hname);
for (j = 1; j < ARGC; j++) {
sub("^[\t ]+", "", header_data[hname, ARGV[j]]);
printf("<td class=\"header\">%s</td>\n", header_data[hname, ARGV[j]]);
}
printf("</tr>\n");
}
printf("<tr>\n");
printf("<th>BENCHMARK</th>\n");
printf("<th align=\"right\">USECS</th>\n");
for (i = 2; i < ARGC; i++)
printf("<th align=\"right\">USECS [percentage]</th>\n");
printf("</tr>\n");
for(i = 1; i < benchmark_count; i++) {
for(j = 1; j < benchmark_count; j++) {
if (benchmarks[j] > benchmarks[j + 1]) {
tmp = benchmarks[j];
benchmarks[j] = benchmarks[j+1];
benchmarks[j+1] = tmp;
}
}
}
for(i = 1; i <= benchmark_count; i++) {
name = benchmarks[i];
a = benchmark_data[name, ARGV[1]];
printf("<tr>\n");
printf("<td>%s</td>\n", name);
if (a > 0)
printf("<td><pre>%f</pre></td>\n", a);
else {
if (a < 0)
printf("<td bgcolor=\"#ff0000\">%s</td>\n", "ERRORS");
else
printf("<td>%s</td>\n", "missing");
for (j = 2; j < ARGC; j++)
printf("<td>%s</td>\n", "not computed");
continue;
}
for (j = 2; j < ARGC; j++) {
b = benchmark_data[name, ARGV[j]];
if (b > 0) {
factor = b/a;
bgcolor = colormap(factor);
if (factor > 1)
percentage = -(factor * 100 - 100);
if (factor <= 1)
percentage = 100/factor - 100;
printf("<td bgcolor=\"%s\"><pre>%11.5f[%#+7.1f%%]</pre></td>\n",
bgcolor, b, percentage);
}
else if (b < 0)
printf("<td bgcolor=\"#ff0000\">%s</td>\n", "ERRORS");
else
printf("<td>%25s</td>\n", "missing");
}
printf("</tr>\n");
}
printf("</tbody></table></body></html>\n");
}
function colormap(value, bgcolor, r, g, b)
{
if (value <= .2)
value = .2;
if (value > 5)
value = 5;
if (value < .9) {
r = colorcalc(.2, value, .9, 0, 255);
g = colorcalc(.2, value, .9, 153, 255);
b = colorcalc(.2, value, .9, 0, 255);
bgcolor=sprintf("#%2.2x%2.2x%2.2x", r, g, b);
}
else if (value < 1.1)
bgcolor="#ffffff";
else {
r = 255;
g = colorcalc(1.1, value, 5, 255, 0);
b = colorcalc(1.1, value, 5, 255, 0);
bgcolor=sprintf("#%2.2x%2.2x%2.2x", r, g, b);
}
return (bgcolor);
}
function colorcalc(min, value, max, mincolor, maxcolor)
{
return((value - min)/(max-min) * (maxcolor-mincolor) + mincolor);
}
' "$@"

View File

@ -1,192 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <strings.h>
#include "libmicro.h"
typedef volatile char vchar_t;
typedef struct {
int ts_once;
vchar_t ** ts_map;
vchar_t ts_foo;
} tsd_t;
#define DEFF "/dev/zero"
#define DEFL 8192
static char *optf = DEFF;
static long long optl = DEFL;
static int optr = 0;
static int optw = 0;
static int opts = 0;
static int fd = -1;
static int anon = 0;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "f:l:rsw");
(void) sprintf(lm_usage,
" [-f file-to-map (default %s)]\n"
" [-l mapping-length (default %d)]\n"
" [-r] (read a byte from each page)\n"
" [-w] (write a byte on each page)\n"
" [-s] (use MAP_SHARED)\n"
"notes: measures munmap()\n",
DEFF, DEFL);
(void) sprintf(lm_header, "%8s %5s", "size", "flags");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'f':
optf = optarg;
anon = strcmp(optf, "MAP_ANON") == 0;
break;
case 'l':
optl = sizetoll(optarg);
break;
case 'r':
optr = 1;
break;
case 's':
opts = 1;
break;
case 'w':
optw = 1;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
if (!anon)
fd = open(optf, O_RDWR);
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i, j;
int errors = 0;
if (ts->ts_once++ == 0) {
ts->ts_map = (vchar_t **)malloc(lm_optB * sizeof (void *));
if (ts->ts_map == NULL) {
errors++;
}
}
for (i = 0; i < lm_optB; i++) {
if (anon) {
ts->ts_map[i] = (vchar_t *)mmap(NULL, optl,
PROT_READ | PROT_WRITE,
MAP_ANON | (opts ? MAP_SHARED : MAP_PRIVATE),
-1, 0L);
} else {
ts->ts_map[i] = (vchar_t *)mmap(NULL, optl,
PROT_READ | PROT_WRITE,
opts ? MAP_SHARED : MAP_PRIVATE,
fd, 0L);
}
if (ts->ts_map[i] == MAP_FAILED) {
errors++;
continue;
}
if (optr) {
for (j = 0; j < optl; j += 4096) {
ts->ts_foo += ts->ts_map[i][j];
}
}
if (optw) {
for (j = 0; j < optl; j += 4096) {
ts->ts_map[i][j] = 1;
}
}
}
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++) {
if (munmap((void *)ts->ts_map[i], optl) == -1) {
res->re_errors++;
}
}
res->re_count += lm_optB;
return (0);
}
char *
benchmark_result()
{
static char result[256];
char flags[5];
flags[0] = anon ? 'a' : '-';
flags[1] = optr ? 'r' : '-';
flags[2] = optw ? 'w' : '-';
flags[3] = opts ? 's' : '-';
flags[4] = 0;
(void) sprintf(result, "%8lld %5s", optl, flags);
return (result);
}

View File

@ -1,194 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* mutex
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/mman.h>
#include "libmicro.h"
static int optt = 0;
static int optp = 0;
static int opth = 0;
static int opto = 0;
pthread_mutex_t *lock;
typedef struct {
int ts_once;
pthread_mutex_t *ts_lock;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_usage,
" [-t] (create dummy thread so we are multithreaded)\n"
" [-p] (use inter-process mutex (not support everywhere))\n"
" [-h usecs] (specify mutex hold time (default 0)\n"
"notes: measures uncontended pthread_mutex_[un,]lock\n");
(void) sprintf(lm_optstr, "tph:o:");
(void) sprintf(lm_header, "%8s", "holdtime");
return (0);
}
/*ARGSUSED*/
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'p':
optp = 1;
break;
case 't':
optt = 1;
break;
case 'h':
opth = sizetoint(optarg);
break;
case 'o':
opto = sizetoint(optarg);
break;
default:
return (-1);
}
return (0);
}
void *
dummy(void *arg)
{
(void) pause();
return (arg);
}
int
benchmark_initrun()
{
pthread_mutexattr_t attr;
int errors = 0;
/*LINTED*/
lock = (pthread_mutex_t *)mmap(NULL,
getpagesize(),
PROT_READ | PROT_WRITE,
optp?(MAP_ANON | MAP_SHARED):MAP_ANON|MAP_PRIVATE,
-1, 0L) + opto;
if (lock == MAP_FAILED) {
errors++;
} else {
(void) pthread_mutexattr_init(&attr);
if (optp)
(void) pthread_mutexattr_setpshared(&attr,
PTHREAD_PROCESS_SHARED);
if (pthread_mutex_init(lock, &attr) != 0)
errors++;
}
return (errors);
}
int
benchmark_initworker(void *tsd)
{
int errors = 0;
tsd_t *ts = (tsd_t *)tsd;
if (optt) {
pthread_t tid;
if (pthread_create(&tid, NULL, dummy, NULL) != 0) {
errors++;
}
}
ts->ts_lock = lock;
return (errors);
}
void
spinme(int usecs)
{
long long s = getusecs();
while (getusecs() - s < usecs)
;
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i ++) {
(void) pthread_mutex_lock(ts->ts_lock);
if (opth)
spinme(opth);
(void) pthread_mutex_unlock(ts->ts_lock);
}
res->re_count = lm_optB;
return (0);
}
char *
benchmark_result()
{
static char result[256];
(void) sprintf(result, "%8d", opth);
return (result);
}

View File

@ -1,63 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* silly nop benchmark to test infrastructure
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "libmicro.h"
int
benchmark_init()
{
(void) sprintf(lm_usage, "notes: measures nothing()\n");
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
int nop();
for (i = 0; i < lm_optB; i++)
(void) nop(); /* do nothing but the call */
res->re_count = i;
return (0);
}

View File

@ -1,138 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* benchmark open
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include "libmicro.h"
typedef struct {
int ts_once;
int *ts_fds;
} tsd_t;
#define DEFF "/dev/null"
static char *optf = DEFF;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
lm_defB = 256;
(void) sprintf(lm_usage,
" [-f file-to-open (default %s)]\n"
"notes: measures open()\n",
DEFF);
(void) sprintf(lm_optstr, "f:");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'f':
optf = optarg;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
(void) setfdlimit(lm_optB * lm_optT + 10);
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int errors = 0;
if (ts->ts_once++ == 0) {
ts->ts_fds = (int *)malloc(lm_optB * sizeof (int));
if (ts->ts_fds == NULL) {
errors++;
}
for (i = 0; i < lm_optB; i++) {
ts->ts_fds[i] = -1;
}
}
return (errors);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++) {
ts->ts_fds[i] = open(optf, O_RDONLY);
if (ts->ts_fds[i] < 0) {
res->re_errors++;
}
}
res->re_count = i;
return (0);
}
int
benchmark_finibatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++) {
(void) close(ts->ts_fds[i]);
}
return (0);
}

View File

@ -1,566 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <pthread.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include "libmicro.h"
typedef struct {
int ts_once;
pid_t ts_child;
pthread_t ts_thread;
int ts_in;
int ts_out;
int ts_in2;
int ts_out2;
int ts_lsn;
struct sockaddr_in ts_add;
} tsd_t;
#define FIRSTPORT 12345
static char *modes[] = {"st", "mt", "mp", NULL};
#define MD_SINGLE 0
#define MD_MULTITHREAD 1
#define MD_MULTIPROCESS 2
static char *xports[] = {"pipe", "fifo", "sock", "tcp",
NULL};
#define XP_PIPES 0
#define XP_FIFOS 1
#define XP_SOCKETPAIR 2
#define XP_LOCALTCP 3
#define DEFM MD_SINGLE
#define DEFS 1024
#define DEFX XP_PIPES
static int optm = DEFM;
static size_t opts = DEFS;
static int optx = DEFX;
static void *rbuf = NULL;
static void *wbuf = NULL;
int readall(int s, void *buf, size_t len);
void *loopback(void *arg);
int prepare_pipes(tsd_t *tsd);
int prepare_fifos(tsd_t *tsd);
int cleanup_fifos(tsd_t *tsd);
int prepare_socketpair(tsd_t *tsd);
int prepare_localtcp(tsd_t *tsd);
int prepare_localtcp_once(tsd_t *tsd);
char *lookupa(int x, char *names[]);
int lookup(char *x, char *names[]);
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "m:s:x:");
(void) sprintf(lm_usage,
" [-m mode (st|mt|mp, default %s)]\n"
" [-s buffer-size (default %d)]\n"
" [-x transport (pipe|fifo|sock|tcp, default %s)]\n"
"notes: measures write()/read() across various transports\n",
lookupa(DEFM, modes), DEFS, lookupa(DEFX, xports));
(void) sprintf(lm_header, "%2s %4s", "md", "xprt");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
int x;
switch (opt) {
case 'm':
x = lookup(optarg, modes);
if (x == -1)
return (-1);
optm = x;
break;
case 's':
opts = sizetoll(optarg);
break;
case 'x':
x = lookup(optarg, xports);
if (x == -1)
return (-1);
optx = x;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
if (optx == XP_FIFOS) {
if (geteuid() != 0) {
(void) printf("sorry, must be root to create fifos\n");
exit(1);
}
}
(void) setfdlimit(4 * lm_optT + 10);
rbuf = malloc(opts);
wbuf = malloc(opts);
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int result;
pid_t pid;
int i;
switch (optx) {
case XP_SOCKETPAIR:
result = prepare_socketpair(ts);
break;
case XP_LOCALTCP:
result = prepare_localtcp(ts);
break;
case XP_FIFOS:
result = prepare_fifos(ts);
break;
case XP_PIPES:
default:
result = prepare_pipes(ts);
break;
}
if (result == -1) {
return (1);
}
switch (optm) {
case MD_MULTITHREAD:
result = pthread_create(&ts->ts_thread, NULL, loopback, tsd);
if (result == -1) {
return (1);
}
break;
case MD_MULTIPROCESS:
pid = fork();
switch (pid) {
case 0:
(void) loopback(tsd);
exit(0);
break;
case -1:
return (-1);
default:
ts->ts_child = pid;
break;
}
break;
case MD_SINGLE:
default:
break;
}
/* Prime the loopback */
if (write(ts->ts_out, wbuf, opts) != opts) {
return (1);
}
if (readall(ts->ts_in, rbuf, opts) != opts) {
return (1);
}
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int n;
for (i = 0; i < lm_optB; i++) {
if (write(ts->ts_out, wbuf, opts) != opts) {
res->re_errors++;
continue;
}
n = readall(ts->ts_in, rbuf, opts);
if (n == -1) {
res->re_errors++;
continue;
}
}
res->re_count = i;
return (0);
}
int
benchmark_finibatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
/* Terminate the loopback */
(void) write(ts->ts_out, wbuf, opts);
(void) readall(ts->ts_in, rbuf, opts);
switch (optm) {
case MD_MULTITHREAD:
(void) close(ts->ts_in2);
(void) close(ts->ts_out2);
(void) pthread_join(ts->ts_thread, NULL);
break;
case MD_MULTIPROCESS:
(void) close(ts->ts_in2);
(void) close(ts->ts_out2);
(void) waitpid(ts->ts_child, NULL, 0);
break;
case MD_SINGLE:
default:
break;
}
(void) close(ts->ts_in);
(void) close(ts->ts_out);
if (optx == XP_FIFOS) {
(void) cleanup_fifos(ts);
}
return (0);
}
char *
benchmark_result()
{
static char result[256];
(void) sprintf(result, "%2s %4s",
lookupa(optm, modes), lookupa(optx, xports));
return (result);
}
int
readall(int s, void *buf, size_t len)
{
size_t n;
size_t total = 0;
for (;;) {
n = read(s, (void *)((long)buf + total), len - total);
if (n < 1) {
return (-1);
}
total += n;
if (total >= len) {
return (total);
}
}
}
void *
loopback(void *arg)
{
tsd_t *ts = (tsd_t *)arg;
int i, n, m;
/* Include priming and termination */
m = lm_optB + 2;
for (i = 0; i < m; i++) {
n = readall(ts->ts_in2, rbuf, opts);
if (n == -1) {
break;
}
if (write(ts->ts_out2, wbuf, opts) != opts) {
break;
}
}
return (NULL);
}
int
prepare_localtcp_once(tsd_t *ts)
{
int j;
int opt = 1;
struct hostent *host;
j = FIRSTPORT;
ts->ts_lsn = socket(AF_INET, SOCK_STREAM, 0);
if (ts->ts_lsn == -1) {
return (-1);
}
if (setsockopt(ts->ts_lsn, SOL_SOCKET, SO_REUSEADDR,
&opt, sizeof (int)) == -1) {
return (-1);
}
if ((host = gethostbyname("localhost")) == NULL) {
return (-1);
}
for (;;) {
(void) memset(&ts->ts_add, 0,
sizeof (struct sockaddr_in));
ts->ts_add.sin_family = AF_INET;
ts->ts_add.sin_port = htons(j++);
(void) memcpy(&ts->ts_add.sin_addr.s_addr,
host->h_addr_list[0], sizeof (struct in_addr));
if (bind(ts->ts_lsn,
(struct sockaddr *)&ts->ts_add,
sizeof (struct sockaddr_in)) == 0) {
break;
}
if (errno != EADDRINUSE) {
return (-1);
}
}
if (listen(ts->ts_lsn, 5) == -1) {
return (-1);
}
return (0);
}
int
prepare_localtcp(tsd_t *ts)
{
int result;
struct sockaddr_in addr;
int opt = 1;
socklen_t size;
if (ts->ts_once++ == 0) {
if (prepare_localtcp_once(ts) == -1) {
return (-1);
}
}
ts->ts_out = socket(AF_INET, SOCK_STREAM, 0);
if (ts->ts_out == -1) {
return (-1);
}
if (fcntl(ts->ts_out, F_SETFL, O_NDELAY) == -1) {
return (-1);
}
result = connect(ts->ts_out, (struct sockaddr *)&ts->ts_add,
sizeof (struct sockaddr_in));
if ((result == -1) && (errno != EINPROGRESS)) {
return (-1);
}
if (fcntl(ts->ts_out, F_SETFL, 0) == -1) {
return (-1);
}
size = sizeof (struct sockaddr);
result = accept(ts->ts_lsn, (struct sockaddr *)&addr, &size);
if (result == -1) {
return (-1);
}
ts->ts_out2 = result;
if (setsockopt(ts->ts_out, IPPROTO_TCP, TCP_NODELAY,
&opt, sizeof (int)) == -1) {
return (-1);
}
if (setsockopt(ts->ts_out2, IPPROTO_TCP, TCP_NODELAY,
&opt, sizeof (int)) == -1) {
return (-1);
}
if (optm == MD_SINGLE) {
ts->ts_in = ts->ts_out2;
} else {
ts->ts_in = ts->ts_out;
ts->ts_in2 = ts->ts_out2;
}
return (0);
}
int
prepare_socketpair(tsd_t *ts)
{
int s[2];
if (socketpair(PF_UNIX, SOCK_STREAM, 0, s) == -1) {
return (-1);
}
if (optm == MD_SINGLE) {
ts->ts_in = s[0];
ts->ts_out = s[1];
} else {
ts->ts_in = s[0];
ts->ts_out = s[0];
ts->ts_in2 = s[1];
ts->ts_out2 = s[1];
}
return (0);
}
int
prepare_fifos(tsd_t *ts)
{
char path[64];
(void) sprintf(path, "/tmp/pipe_%ld.%dA",
getpid(), pthread_self());
if (mknod(path, 0600, S_IFIFO) == -1) {
return (-1);
}
if (optm == MD_SINGLE) {
ts->ts_in = open(path, O_RDONLY);
ts->ts_out = open(path, O_WRONLY);
} else {
ts->ts_in = open(path, O_RDONLY);
ts->ts_out2 = open(path, O_WRONLY);
(void) sprintf(path, "/tmp/pipe_%ld.%dB",
getpid(), pthread_self());
if (mknod(path, 0600, S_IFIFO) == -1) {
return (-1);
}
ts->ts_in2 = open(path, O_RDONLY);
ts->ts_out = open(path, O_WRONLY);
}
return (0);
}
/*ARGSUSED*/
int
cleanup_fifos(tsd_t *ts)
{
char path[64];
(void) sprintf(path, "/tmp/pipe_%ld.%dA", getpid(), pthread_self());
(void) unlink(path);
(void) sprintf(path, "/tmp/pipe_%ld.%dB", getpid(), pthread_self());
(void) unlink(path);
return (0);
}
int
prepare_pipes(tsd_t *ts)
{
int p[2];
if (optm == MD_SINGLE) {
if (pipe(p) == -1) {
return (-1);
}
ts->ts_in = p[0];
ts->ts_out = p[1];
} else {
if (pipe(p) == -1) {
return (-1);
}
ts->ts_in = p[0];
ts->ts_out2 = p[1];
if (pipe(p) == -1) {
return (-1);
}
ts->ts_in2 = p[0];
ts->ts_out = p[1];
}
return (0);
}
char *
lookupa(int x, char *names[])
{
int i = 0;
while (names[i] != NULL) {
if (x == i) {
return (names[i]);
}
i++;
}
return (NULL);
}
int
lookup(char *x, char *names[])
{
int i = 0;
while (names[i] != NULL) {
if (strcmp(names[i], x) == 0) {
return (i);
}
i++;
}
return (-1);
}

View File

@ -1,218 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define MIN(x, y) ((x) > (y) ? (y) : (x))
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <poll.h>
#include <sys/socket.h>
#include "libmicro.h"
#define DEFN 256
static int optn = DEFN;
static int optr = 0;
static int optw = 0;
static int optx = 0;
static int *fds;
static int target = 0;
typedef struct pollfd pfd_t;
typedef struct {
int ts_once;
pfd_t *ts_pfds;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "n:r:w:x");
(void) sprintf(lm_usage,
" [-n fds-per-thread (default %d)]\n"
" [-r readable-fds (default 0)]\n"
" [-w writeable-fds (default 0)]\n"
" [-x] (start -r option with highest fd first; "
"default is lowest first)\n"
"notes: measures poll()\n",
DEFN);
(void) sprintf(lm_header, "%8s %5s", "nfds", "flags");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'n':
optn = atoi(optarg);
break;
case 'r':
optr = atoi(optarg);
break;
case 'w':
optw = atoi(optarg);
break;
case 'x':
optx = 1;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
int i;
int j;
int pair[2];
if (optn % 2 != 0) {
(void) printf("ERROR: -n value must be even\n");
optn = optr = optw = 0;
return (-1);
}
if (optn < 0 || optr < 0 || optw < 0) {
(void) printf("ERROR: -n, -r and -w values must be > 0\n");
optn = optr = optw = 0;
return (-1);
}
if (optr > optn || optw > optn) {
(void) printf("ERROR: -r and -w values must be <= maxfd\n");
optn = optr = optw = 0;
return (-1);
}
fds = (int *)malloc(optn * sizeof (int));
if (fds == NULL) {
(void) printf("ERROR: malloc() failed\n");
optn = optr = optw = 0;
return (-1);
}
(void) setfdlimit(optn + 10);
for (i = 0; i < optn; i += 2) {
if (socketpair(PF_UNIX, SOCK_STREAM, 0, pair) == -1) {
(void) printf("ERROR: socketpair() failed\n");
return (-1);
}
fds[i] = MIN(pair[0], pair[1]);
fds[i+1] = MAX(pair[0], pair[1]);
}
if (optx) {
target = MIN(optr + optw, optn);
for (i = 0, j = optn - 1; i < optr; i++, j--) {
(void) write(fds[j+1 - (2*(j%2))], "", 1);
}
} else {
target = MAX(optr, optw);
for (i = 0; i < optr; i++) {
(void) write(fds[i+1 - (2*(i%2))], "", 1);
}
}
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int errors = 0;
if (ts->ts_once++ == 0) {
ts->ts_pfds = (pfd_t *)malloc(optn * sizeof (pfd_t));
if (ts->ts_pfds == NULL) {
errors++;
}
for (i = 0; i < optn; i++) {
ts->ts_pfds[i].fd = fds[i];
ts->ts_pfds[i].events = POLLIN;
}
for (i = 0; i < optw; i++) {
ts->ts_pfds[i].events |= POLLOUT;
}
}
return (errors);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++) {
if (poll(ts->ts_pfds, optn, 0) != target) {
res->re_errors++;
}
}
res->re_count = i;
return (0);
}
char *
benchmark_result()
{
static char result[256];
char flags[4];
flags[0] = optr ? 'r' : '-';
flags[1] = optw ? 'w' : '-';
flags[2] = optx ? 'x' : '-';
flags[3] = 0;
(void) sprintf(result, "%8d %5s", optn, flags);
return (result);
}

View File

@ -1,142 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifdef linux
#define _XOPEN_SOURCE 500
#endif
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include "libmicro.h"
typedef struct {
char *ts_buf;
} tsd_t;
#define DEFF "/dev/zero"
#define DEFS 1024
static char *optf = DEFF;
static long long opts = DEFS;
static int optw = 0;
static int fd = -1;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "wf:s:");
(void) sprintf(lm_usage,
" [-f file-to-read (default %s)]\n"
" [-s buffer-size (default %d)]\n"
" [-w (write a byte to each page after read)]\n"
"notes: measures pread()\n",
DEFF, DEFS);
(void) sprintf(lm_header, "%8s", "size");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'w':
optw = getpagesize();
break;
case 'f':
optf = optarg;
break;
case 's':
opts = sizetoll(optarg);
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
fd = open(optf, O_RDONLY);
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int errors = 0;
if (ts->ts_buf == NULL) {
ts->ts_buf = malloc(opts);
}
return (errors);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int j;
for (i = 0; i < lm_optB; i++) {
if (pread(fd, ts->ts_buf, opts, 0) != opts) {
res->re_errors++;
}
if (optw) {
for (j = 0; j < opts; j += optw)
ts->ts_buf[j] = 0;
}
}
res->re_count = i;
return (0);
}
char *
benchmark_result()
{
static char result[256];
(void) sprintf(result, "%8lld", opts);
return (result);
}

View File

@ -1,160 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <errno.h>
#include "libmicro.h"
typedef struct {
pthread_t *ts_threads;
pthread_attr_t *ts_attr;
pthread_mutex_t ts_lock;
} tsd_t;
static int opts = 0;
int
benchmark_init()
{
lm_defN = "pthread";
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_usage,
" [-s stacksize] (specify stacksize)\n"
"notes: measures pthread_create\n");
(void) sprintf(lm_optstr, "s:");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 's':
opts = sizetoll(optarg);
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initworker(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int errors = 0;
ts->ts_threads = calloc(lm_optB, sizeof (pthread_t));
(void) pthread_mutex_init(&ts->ts_lock, NULL);
if (opts) {
ts->ts_attr = malloc(sizeof (pthread_attr_t));
(void) pthread_attr_init(ts->ts_attr);
if ((errors = pthread_attr_setstacksize(ts->ts_attr, opts))
!= 0) {
errno = errors;
perror("pthread_attr_setstacksize");
}
} else
ts->ts_attr = NULL;
return (errors?1:0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
(void) pthread_mutex_lock(&ts->ts_lock);
return (0);
}
void *
func(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
(void) pthread_mutex_lock(&ts->ts_lock);
(void) pthread_mutex_unlock(&ts->ts_lock);
return (tsd);
}
int
benchmark(void *tsd, result_t *res)
{
int i;
tsd_t *ts = (tsd_t *)tsd;
int error;
for (i = 0; i < lm_optB; i++) {
if ((error = pthread_create(ts->ts_threads + i,
ts->ts_attr, func, tsd)) != 0) {
errno = error;
perror("pthread_create");
ts->ts_threads[i] = 0;
res->re_errors++;
return (0);
}
}
res->re_count = lm_optB;
return (0);
}
int
benchmark_finibatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int errors = 0;
(void) pthread_mutex_unlock(&ts->ts_lock);
for (i = 0; i < lm_optB; i++)
if (ts->ts_threads[i] == 0 ||
pthread_join(ts->ts_threads[i], NULL) < 0) {
errors++;
}
return (errors);
}

View File

@ -1,154 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifdef linux
#define _XOPEN_SOURCE 500
#endif
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include "libmicro.h"
typedef struct {
char *ts_buf;
} tsd_t;
#define DEFF "/dev/null"
#define DEFS 1024
static int optc = 0;
static char *optf = DEFF;
static long long opts = DEFS;
static int fd = -1;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "cf:s:");
(void) sprintf(lm_usage,
" [-f file-to-write (default %s)]\n"
" [-s buffer-size (default %d)]\n"
" [-c ] (make sure buffer is in cache)\n"
"notes: measures pwrite()\n",
DEFF, DEFS);
(void) sprintf(lm_header, "%8s", "size");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'c':
optc++;
break;
case 'f':
optf = optarg;
break;
case 's':
opts = sizetoll(optarg);
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
fd = open(optf, O_WRONLY);
if (fd == -1) {
return (-1);
}
return (0);
}
int
benchmark_finirun()
{
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
if (ts->ts_buf == NULL) {
ts->ts_buf = malloc(opts);
/*
* bring buf into cache if specified.
*/
if (optc)
for (i = 0; i < opts; i++)
ts->ts_buf[i] = 0;
}
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
for (i = 0; i < lm_optB; i++) {
if (pwrite(fd, ts->ts_buf, opts, 0) != opts) {
res->re_errors++;
}
}
res->re_count = i;
return (0);
}
char *
benchmark_result()
{
static char result[256];
(void) sprintf(result, "%8lld", opts);
return (result);
}

View File

@ -1,143 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifdef linux
#define _XOPEN_SOURCE 500
#endif
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include "libmicro.h"
typedef struct {
char *ts_buf;
int ts_fd;
} tsd_t;
#define DEFF "/dev/zero"
#define DEFS 1024
static char *optf = DEFF;
static long long opts = DEFS;
int optw = 0;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "f:s:w");
(void) sprintf(lm_usage,
" [-f file-to-read (default %s)]\n"
" [-s buffer-size (default %d)]\n"
" [-w (store a byte to each page after read)]\n"
"notes: measures read()\n",
DEFF, DEFS);
(void) sprintf(lm_header, "%8s", "size");
lm_defB = 1;
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'w':
optw = getpagesize();
break;
case 'f':
optf = optarg;
break;
case 's':
opts = sizetoll(optarg);
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
if (ts->ts_buf == NULL) {
ts->ts_buf = malloc(opts);
ts->ts_fd = open(optf, O_RDONLY);
}
(void) lseek(ts->ts_fd, 0, SEEK_SET);
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i;
int j;
for (i = 0; i < lm_optB; i++) {
if (read(ts->ts_fd, ts->ts_buf, opts) != opts) {
res->re_errors++;
}
if (optw)
for (j = 0; j < opts; j += optw)
ts->ts_buf[j] = 0;
}
res->re_count = i;
return (0);
}
char *
benchmark_result()
{
static char result[256];
(void) sprintf(result, "%8lld", opts);
return (result);
}

View File

@ -1,85 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "libmicro.h"
#define DEFF "/"
#define MAXPATHLEN 1024
static char *optf = DEFF;
int
benchmark_init()
{
(void) sprintf(lm_optstr, "f:");
lm_tsdsize = 0;
(void) sprintf(lm_usage,
" [-f directory (default = %s)]\n"
"notes: measures realpath()\n",
DEFF);
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'f':
optf = optarg;
break;
default:
return (-1);
}
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
char path[MAXPATHLEN];
for (i = 0; i < lm_optB; i++) {
if (realpath(optf, path) == NULL)
res->re_errors++;
}
res->re_count = i;
return (0);
}

View File

@ -1,98 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libmicro.h"
#define DEFD 100
static int optd = DEFD;
int recurse2(int x, int y, char *s);
/*ARGSUSED*/
int
recurse1(int x, int y, char *s)
{
char str[32];
if (x < y) {
return (recurse2(x + 1, y, str));
}
return (x);
}
int
benchmark_init()
{
lm_tsdsize = 0;
(void) sprintf(lm_optstr, "d:");
(void) sprintf(lm_usage,
" [-d depth-limit (default = %d)]\n"
"notes: measures recursion performance\n",
DEFD);
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'd':
optd = atoi(optarg);
break;
default:
return (-1);
}
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
for (i = 0; i < lm_optB; i++) {
(void) recurse1(0, optd, NULL);
}
res->re_count = i;
return (0);
}

View File

@ -1,46 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <string.h>
int recurse1(int x, int y, char *s);
/*ARGSUSED*/
int
recurse2(int x, int y, char *s)
{
char str[32];
if (x < y) {
return (recurse1(x + 1, y, str));
}
return (x);
}

View File

@ -1,214 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define MIN(x, y) ((x) > (y) ? (y) : (x))
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/socket.h>
#include "libmicro.h"
#define DEFN 256
static int optn = DEFN;
static int optr = 0;
static int optw = 0;
static int optx = 0;
static int *fds;
static fd_set iset;
static fd_set oset;
static int maxfd = 0;
static int target = 0;
int
benchmark_init()
{
(void) sprintf(lm_optstr, "n:r:w:x");
lm_tsdsize = 0;
(void) sprintf(lm_usage,
" [-n fds-per-thread (default %d)]\n"
" [-r readable-fds (default 0)]\n"
" [-w writeable-fds (default 0)]\n"
" [-x] (start -r option with highest fd first; "
"default is lowest first)\n"
"notes: measures select()\n",
DEFN);
(void) sprintf(lm_header, "%8s %5s", "maxfd", "flags");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'n':
optn = atoi(optarg);
break;
case 'r':
optr = atoi(optarg);
break;
case 'w':
optw = atoi(optarg);
break;
case 'x':
optx = 1;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
int i;
int j;
int pair[2];
if (optn % 2 != 0) {
(void) printf("ERROR: -n value must be even\n");
optn = optr = optw = 0;
return (-1);
}
if (optn < 0 || optr < 0 || optw < 0) {
(void) printf("ERROR: -n, -r and -w values must be > 0\n");
optn = optr = optw = 0;
return (-1);
}
if (optr > optn || optw > optn) {
(void) printf("ERROR: -r and -w values must be <= maxfd\n");
optn = optr = optw = 0;
return (-1);
}
fds = (int *)malloc(optn * sizeof (int));
if (fds == NULL) {
(void) printf("ERROR: malloc() failed\n");
optn = optr = optw = 0;
return (-1);
}
(void) setfdlimit(optn + 10);
target = optr + optw;
FD_ZERO(&iset);
FD_ZERO(&oset);
for (i = 0; i < optn; i += 2) {
if (socketpair(PF_UNIX, SOCK_STREAM, 0, pair) == -1) {
(void) printf("ERROR: socketpair() failed\n");
return (-1);
}
fds[i] = MIN(pair[0], pair[1]);
fds[i+1] = MAX(pair[0], pair[1]);
maxfd = fds[i+1] + 1;
if (maxfd > FD_SETSIZE) {
(void) printf("WARNING: FD_SETSIZE is too small!\n");
return (-1);
}
FD_SET(fds[i], &iset);
FD_SET(fds[i+1], &iset);
}
for (i = 0; i < optw; i++) {
FD_SET(fds[i], &oset);
}
if (optx) {
for (i = 0, j = optn - 1; i < optr; i++, j--) {
(void) write(fds[j+1 - (2*(j%2))], "", 1);
}
} else {
for (i = 0; i < optr; i++) {
(void) write(fds[i+1 - (2*(i%2))], "", 1);
}
}
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
fd_set set1;
fd_set set2;
fd_set *my_iset = &set1;
fd_set *my_oset = NULL;
struct timeval tv = {0, 0};
if (optw) {
my_oset = &set2;
}
for (i = 0; i < lm_optB; i++) {
(void) memcpy(&set1, &iset, sizeof (fd_set));
(void) memcpy(&set2, &oset, sizeof (fd_set));
if (select(maxfd, my_iset, my_oset, NULL, &tv) != target) {
res->re_errors++;
}
}
res->re_count = i;
return (0);
}
char *
benchmark_result()
{
static char result[256];
char flags[4];
flags[0] = optr ? 'r' : '-';
flags[1] = optw ? 'w' : '-';
flags[2] = optx ? 'x' : '-';
flags[3] = 0;
(void) sprintf(result, "%8d %5s", optn, flags);
return (result);
}

View File

@ -1,103 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include "libmicro.h"
typedef struct {
int ts_semid;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_usage, "notes: measures semop()\n");
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
if ((ts->ts_semid = semget(IPC_PRIVATE, 2, 0600)) == -1) {
return (-1);
}
return (0);
}
int
benchmark_finibatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
(void) semctl(ts->ts_semid, 0, IPC_RMID);
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
int i;
tsd_t *ts = (tsd_t *)tsd;
struct sembuf s[1];
for (i = 0; i < lm_optB; i++) {
s[0].sem_num = 0;
s[0].sem_op = 1;
s[0].sem_flg = 0;
if (semop(ts->ts_semid, s, 1) == -1) {
res->re_errors++;
}
s[0].sem_num = 0;
s[0].sem_op = -1;
s[0].sem_flg = 0;
if (semop(ts->ts_semid, s, 1) == -1) {
res->re_errors++;
}
}
res->re_count += lm_optB;
return (0);
}

View File

@ -1,67 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <ucontext.h>
#include "libmicro.h"
int
benchmark_init()
{
(void) sprintf(lm_usage, "notes: measures setcontext()\n");
lm_tsdsize = 0;
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
volatile int i;
ucontext_t uc;
i = 0;
(void) getcontext(&uc);
if (i++ < lm_optB)
(void) setcontext(&uc);
res->re_count += lm_optB;
return (0);
}

View File

@ -1,99 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include "libmicro.h"
typedef struct {
int ts_fd;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_usage, "setsockopt(TCP_NODELAY)\n");
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
if ((ts->ts_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
return (1);
return (0);
}
int
benchmark_finibatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
(void) close(ts->ts_fd);
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
int i;
tsd_t *ts = (tsd_t *)tsd;
int opt;
res->re_errors = 0;
for (i = 0; i < lm_optB; i++) {
opt = 1 & i;
if (setsockopt(ts->ts_fd, IPPROTO_TCP, TCP_NODELAY,
&opt, sizeof (int)) == -1) {
res->re_errors ++;
}
}
res->re_count += lm_optB;
return (0);
}

View File

@ -1,95 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include "libmicro.h"
#ifdef __sun
static void
nop()
{
}
#else
static void
nop(int sig)
{
}
#endif
typedef struct {
struct sigaction ts_act;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_usage, "notes: measures sigaction()\n");
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
ts->ts_act.sa_handler = nop;
ts->ts_act.sa_flags = 0;
(void) sigemptyset(&ts->ts_act.sa_mask);
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
int i;
tsd_t *ts = (tsd_t *)tsd;
struct sigaction oact;
res->re_errors = 0;
for (i = 0; i < lm_optB; i++) {
if (sigaction(SIGUSR1, &ts->ts_act, &oact))
res->re_errors++;
}
res->re_count += lm_optB;
return (0);
}

View File

@ -1,69 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#include "libmicro.h"
typedef struct {
jmp_buf ts_env;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
lm_tsdsize = 0;
(void) sprintf(lm_usage, "notes: measures siglongjmp()\n");
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
tsd_t *ts = (tsd_t *)tsd;
int i = 0;
(void) sigsetjmp(ts->ts_env, 1);
if (i++ < lm_optB)
siglongjmp(ts->ts_env, 0);
res->re_count = lm_optB;
return (0);
}

View File

@ -1,100 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include "libmicro.h"
#ifdef __sun
static void
nop()
{
}
#else
static void
nop(int sig)
{
}
#endif
int
benchmark_init()
{
lm_tsdsize = 0;
(void) sprintf(lm_usage, "notes: measures signal()\n");
return (0);
}
int
benchmark_initrun()
{
struct sigaction act;
act.sa_handler = nop;
act.sa_flags = 0;
(void) sigemptyset(&act.sa_mask);
(void) sigaction(SIGUSR1, &act, NULL);
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
int pid;
pid = getpid();
for (i = 0; i < lm_optB; i += 10) {
(void) kill(pid, SIGUSR1);
(void) kill(pid, SIGUSR1);
(void) kill(pid, SIGUSR1);
(void) kill(pid, SIGUSR1);
(void) kill(pid, SIGUSR1);
(void) kill(pid, SIGUSR1);
(void) kill(pid, SIGUSR1);
(void) kill(pid, SIGUSR1);
(void) kill(pid, SIGUSR1);
(void) kill(pid, SIGUSR1);
}
res->re_count += lm_optB;
return (0);
}

View File

@ -1,84 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include "libmicro.h"
int
benchmark_init()
{
lm_tsdsize = 0;
(void) sprintf(lm_usage, "notes: measures sigprocmask()\n");
return (0);
}
int
benchmark_initrun()
{
sigset_t iset;
(void) sigemptyset(&iset);
(void) sigprocmask(SIG_SETMASK, &iset, NULL);
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
sigset_t set0, set1;
(void) sigemptyset(&set0);
(void) sigaddset(&set0, SIGTERM);
for (i = 0; i < lm_optB; i += 10) {
(void) sigprocmask(SIG_SETMASK, &set0, &set1);
(void) sigprocmask(SIG_SETMASK, &set1, &set0);
(void) sigprocmask(SIG_SETMASK, &set0, &set1);
(void) sigprocmask(SIG_SETMASK, &set1, &set0);
(void) sigprocmask(SIG_SETMASK, &set0, &set1);
(void) sigprocmask(SIG_SETMASK, &set1, &set0);
(void) sigprocmask(SIG_SETMASK, &set0, &set1);
(void) sigprocmask(SIG_SETMASK, &set1, &set0);
(void) sigprocmask(SIG_SETMASK, &set0, &set1);
(void) sigprocmask(SIG_SETMASK, &set1, &set0);
}
res->re_count += lm_optB;
return (0);
}

View File

@ -1,157 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include "libmicro.h"
typedef struct {
int ts_once;
int *ts_fds;
} tsd_t;
#define DEFF "PF_UNIX"
static char *optf = DEFF;
static int family;
int
lookup_family(char *name)
{
if (strcmp("PF_UNIX", name) == 0) {
return (PF_UNIX);
} else if (strcmp("PF_INET", name) == 0) {
return (PF_INET);
} else if (strcmp("PF_INET6", name) == 0) {
return (PF_INET6);
}
return (-1);
}
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
lm_defB = 256;
(void) sprintf(lm_optstr, "f:n");
(void) sprintf(lm_usage,
" [-f socket-family (default %s)]\n"
"notes: measures socket\n",
DEFF);
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'f':
optf = optarg;
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initrun()
{
(void) setfdlimit(lm_optB * lm_optT + 10);
family = lookup_family(optf);
return (0);
}
int
benchmark_finirun()
{
return (0);
}
int
benchmark_initbatch(void *tsd)
{
int i;
tsd_t *ts = (tsd_t *)tsd;
if (ts->ts_once++ == 0) {
ts->ts_fds = (int *)malloc(lm_optB * sizeof (int));
if (ts->ts_fds == NULL) {
return (1);
}
for (i = 0; i < lm_optB; i++) {
ts->ts_fds[i] = -1;
}
}
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
int i;
tsd_t *ts = (tsd_t *)tsd;
for (i = 0; i < lm_optB; i++) {
ts->ts_fds[i] = socket(family, SOCK_STREAM, 0);
if (ts->ts_fds[i] == -1) {
res->re_errors++;
}
}
res->re_count += lm_optB;
return (0);
}
int
benchmark_finibatch(void *tsd)
{
int i;
tsd_t *ts = (tsd_t *)tsd;
for (i = 0; i < lm_optB; i++) {
(void) close(ts->ts_fds[i]);
}
return (0);
}

View File

@ -1,118 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include "libmicro.h"
typedef struct {
int ts_once;
int *ts_fds;
} tsd_t;
#define DEFN 256
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
lm_defB = 256;
(void) sprintf(lm_usage,
"notes: measures socketpair\n");
return (0);
}
int
benchmark_initrun()
{
(void) setfdlimit(lm_optB * lm_optT + 10);
return (0);
}
int
benchmark_initbatch(void *tsd)
{
int i;
tsd_t *ts = (tsd_t *)tsd;
if (ts->ts_once++ == 0) {
ts->ts_fds = (int *)malloc(lm_optB * sizeof (int));
if (ts->ts_fds == NULL) {
return (1);
}
for (i = 0; i < lm_optB; i++) {
ts->ts_fds[i] = -1;
}
}
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
int i;
tsd_t *ts = (tsd_t *)tsd;
res->re_count = 0;
res->re_errors = 0;
for (i = 0; i < lm_optB; i += 2) {
if (socketpair(PF_UNIX, SOCK_STREAM, 0, &ts->ts_fds[i])
== -1) {
res->re_errors++;
}
}
res->re_count = lm_optB / 2;
return (0);
}
int
benchmark_finibatch(void *tsd)
{
int i;
tsd_t *ts = (tsd_t *)tsd;
for (i = 0; i < lm_optB; i++) {
(void) close(ts->ts_fds[i]);
}
return (0);
}

View File

@ -1,88 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "libmicro.h"
#define DEFF "/dev/null"
static char *optf = DEFF;
int
benchmark_init()
{
(void) sprintf(lm_optstr, "f:");
lm_tsdsize = 0;
(void) sprintf(lm_usage,
" [-f file-to-stat (default %s)]\n"
"notes: measures stat()\n",
DEFF);
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'f':
optf = optarg;
break;
default:
return (-1);
}
return (0);
}
/*ARGSUSED*/
int
benchmark(void *tsd, result_t *res)
{
int i;
struct stat sbuf;
res->re_errors = 0;
for (i = 0; i < lm_optB; i++) {
if (stat(optf, &sbuf) == -1)
res->re_errors++;
}
res->re_count += lm_optB;
return (0);
}

View File

@ -1,150 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "libmicro.h"
static int unaligned = 0;
static int opts = 100;
typedef struct {
int ts_once;
char *ts_a;
char *ts_b;
int ts_fakegcc;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "s:n");
(void) sprintf(lm_usage,
" [-s string size (default %d)]\n"
" [-n causes unaligned cmp]\n"
"notes: measures strcasecmp()\n",
opts);
(void) sprintf(lm_header, "%8s", "size");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'n':
unaligned = 1;
break;
case 's':
opts = sizetoll(optarg);
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
static char *demo =
"The quick brown fox jumps over the lazy dog.";
if (ts->ts_once++ == 0) {
int l = strlen(demo);
int i;
ts->ts_a = malloc(opts + 1);
ts->ts_b = malloc(opts + 1 + unaligned);
ts->ts_b += unaligned;
for (i = 0; i < opts; i++) {
ts->ts_a[i] = ts->ts_b[i] = demo[i%l];
}
ts->ts_a[opts] = 0;
ts->ts_b[opts] = 0;
}
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
int i;
tsd_t *ts = (tsd_t *)tsd;
char *src = ts->ts_a;
char *src2 = ts->ts_b;
int *sum = &ts->ts_fakegcc;
res->re_errors = 0;
for (i = 0; i < lm_optB; i += 10) {
*sum += strcasecmp(src, src2);
*sum += strcasecmp(src, src2);
*sum += strcasecmp(src, src2);
*sum += strcasecmp(src, src2);
*sum += strcasecmp(src, src2);
*sum += strcasecmp(src, src2);
*sum += strcasecmp(src, src2);
*sum += strcasecmp(src, src2);
*sum += strcasecmp(src, src2);
*sum += strcasecmp(src, src2);
}
res->re_count = lm_optB;
return (0);
}
char *
benchmark_result()
{
static char result[256];
if (unaligned == 0)
(void) sprintf(result, "%8d", opts);
else
(void) sprintf(result, "%8d <unaligned>", opts);
return (result);
}

View File

@ -1,144 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the "License"). You may not use this file except
* in compliance with the License.
*
* You can obtain a copy of the license at
* src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* HEADER in each file and include the License file at
* usr/src/OPENSOLARIS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your
* own identifying information: Portions Copyright [yyyy]
* [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "libmicro.h"
static int unaligned = 0;
static int opts = 100;
typedef struct {
int ts_once;
char *ts_string;
char *ts_fakegcc;
} tsd_t;
int
benchmark_init()
{
lm_tsdsize = sizeof (tsd_t);
(void) sprintf(lm_optstr, "s:n");
(void) sprintf(lm_usage,
" [-s string size (default %d)]\n"
" [-n causes unaligned strchr]\n"
"notes: measures strchr()\n",
opts);
(void) sprintf(lm_header, "%8s", "size");
return (0);
}
int
benchmark_optswitch(int opt, char *optarg)
{
switch (opt) {
case 'n':
unaligned = 1;
break;
case 's':
opts = sizetoll(optarg);
break;
default:
return (-1);
}
return (0);
}
int
benchmark_initbatch(void *tsd)
{
tsd_t *ts = (tsd_t *)tsd;
static char *demo =
"The quick brown fox jumps over the lazy dog.";
if (ts->ts_once++ == 0) {
int l = strlen(demo);
int i;
ts->ts_string = malloc(opts + 1 + unaligned);
ts->ts_string += unaligned;
for (i = 0; i < opts; i++) {
ts->ts_string[i] = demo[i%l];
}
ts->ts_string[opts] = 0;
}
return (0);
}
int
benchmark(void *tsd, result_t *res)
{
int i;
tsd_t *ts = (tsd_t *)tsd;
char *src = ts->ts_string;
for (i = 0; i < lm_optB; i += 10) {
ts->ts_fakegcc = strchr(src, 'X');
ts->ts_fakegcc = strchr(src, 'X');
ts->ts_fakegcc = strchr(src, 'X');
ts->ts_fakegcc = strchr(src, 'X');
ts->ts_fakegcc = strchr(src, 'X');
ts->ts_fakegcc = strchr(src, 'X');
ts->ts_fakegcc = strchr(src, 'X');
ts->ts_fakegcc = strchr(src, 'X');
ts->ts_fakegcc = strchr(src, 'X');
ts->ts_fakegcc = strchr(src, 'X');
}
res->re_count = lm_optB;
return (0);
}
char *
benchmark_result()
{
static char result[256];
if (unaligned == 0)
(void) sprintf(result, "%8d", opts);
else
(void) sprintf(result, "%8d <unaligned>", opts);
return (result);
}

Some files were not shown because too many files have changed in this diff Show More