alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (bench)

This example Scala source code file (bench) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Scala tags/keywords

artifact, artifact, artifact_path, artifact_path, class_dir, class_dir, classpath, fsc, if, runcommand, runcommand, scala_libs_path, src_dir, top_dir

The Scala bench source code


#################################################################
#  
# A simple script used to rebuild benchmarks using fsc and then run them.
# If you need to rebuild, use: 
# 
#   ./bench <arguments>
# 
# Omitting <arguments> will print more information.
# If you don't want to rebuild:
# 
#   ./bench skip <same-args-as-above>
#
#################################################################


TOP_DIR=$PWD
# build/pack for ant, target/pack for sbt
SCALA_BUILD_DIR=../../target/pack 
SRC_DIR=src/
TARGET_DIR=target
CLASS_DIR=$TARGET_DIR/classes

FSC=$SCALA_BUILD_DIR/bin/fsc
SCALA_LIBS_PATH=$SCALA_BUILD_DIR/lib
CLASSPATH=$SCALA_LIBS_PATH/scala-library.jar:lib/jsr166_and_extra.jar

ARTIFACT=benchmarks.jar
ARTIFACT_PATH=$TARGET_DIR/$ARTIFACT


if [ "$1" != "skip" ]
then
  # fetch source file list
  find $SRC_DIR -name *.scala -print > source.list
  
  # recompile with fsc
  $FSC -cp $CLASSPATH -d $CLASS_DIR @source.list
  
  # copy files
  cd $SRC_DIR
  cp -r * ../$CLASS_DIR
  cd ..
  
  # jar it up
  rm $ARTIFACT_PATH
  cd $CLASS_DIR
  jar cf $ARTIFACT .
  mv $ARTIFACT $TOP_DIR/$ARTIFACT_PATH
  cd $TOP_DIR
fi

# run a benchmark
RUNCOMMAND="java -Xms256m -Xmx512m -server -cp $CLASSPATH:$ARTIFACT_PATH scala.collection.parallel.Benchmarking "
if [ "$1" != skip ]
then
  $RUNCOMMAND "$@"
else
  $RUNCOMMAND $2 $3 $4 $5 $6 $7 $8
fi



Other Scala examples (source code examples)

Here is a short list of links related to this Scala bench source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.