Bit's World

Hope the best,plan the worst!

Subscribe to RSS feed

benchmark tools (zz)

Interbench: http://users.on.net/~ckolivas/interbench/
Interactivity benchmark. Measures the system latency under various simulated load conditions. Supports real-time tasks.

Netperf: http://www.netperf.org/netperf/NetperfPage.html
Measures networking performance.

Hackbench: http://developer.osdl.org/craiger/hackbench/
Tests the performance, overhead and scalability of the Linux scheduler.

dbench: http://samba.org/ftp/tridge/dbench/README
Produces filesystem load.

stress: http://weather.ou.edu/~apw/projects/stress/
System load generator (CPU, memory, I/O, disk)

Edit video file with mencoder under linux

,

It's quite easy to use mencoder command to do some simple edit with the video file, here is the most useful tips when we make simple edit to video file.

- Join several videos:
mencoder -oac copy -ovc copy -idx -o output.avi v1.avi v2.avi v3.avi
"oac" for output audio encoding, "ovc" for output video encoding.

- Synchronise sound and video
First you can try to determine how much delay between the video and audo with:
 mplayer -delay 0.5 1.avi
Here 0.5 means the audio will be played 0.5 second earlier, it could be negative or positive value. Once you get the audio and video correctly player, you can synchronise the the video and audio with command like:
mencoder -delay 0.7 -oac copy -ovc copy video.avi -o output.avi

- Trim video
You can either trim the video from the start or the end with command like:
mencoder -ss 00:00:24 -oac copy -ovc copy i.avi -o o.avi
This command replace the 24 seconds as the desired start time.
 mencoder -ss 00:00:24 -endpos 00:14:00 -oac copy -ovc copy i.avi -o o.avi
This command replace the 24 seconds as the desired start time and the following 14 minutes as output video. With the "-ss" and "-endpos" options, we can split video as we expected. Then we can use the previous join videos command to concatenate the videos.

- Remove/Merge audio
To remove the current audio track, we can try command like:
mencoder -ovc copy -nosound video.avi -o silent.avi
To place a new audio track to the video, we can try command like:
mencoder -ovc copy -audiofile sound.mp3 -oac copy silent.avi -o new.avi

A simple script to show changes with diff tool in unified diff format made in current clearcase view

The output format of clearcase's "cleartool diff" is not in unified diff format and is not good for code review. Even clearase supports type manager to use third party diff tool in cleartool command, as for simple use of command line, I came up this simple bash script. You can just use it under your working dynamic view's directory, and it will show all checked out file's changes you have made.

#!/bin/bash
# script to list diffs under current directory. 
#
IFS_OLD=$IFS
IFS=$'\x0a'
for i in $(cleartool lsco -r -cview -fmt "%n %PVn\n")
do
        IFS=$IFS_OLD
        set -- $i
        file=$(echo $1 | sed "s/^\([\"']\)\(.*\)\1\$/\2/g")
        file=$( readlink -f "$( dirname "$file" )" )/$( basename "$file" )
        if [ -f $file ]
        then
                #echo $file
                diff -u $file@@$2 $file
        fi
done

Updated dwm start script

,

I like the lightweight tiling window manager dwm.

Here is the update start script added date and background updating.

#!/bin/bash
DIR=${HOME}/.dwm
if [ -f "${DIR}"/dwmrc ]; then
    /bin/sh "${DIR}"/dwmrc &
else
    while true; do
        xsetroot -name "`date`"
        sleep 1
    done &
fi
# set up background.
WALLPAPERS="/usr/share/backgrounds"
while true; do
    ALIST=( `ls -w1 $WALLPAPERS | grep jpg`)
    RANGE=${#ALIST[*]}
    SHOW=$(( $RANDOM % $RANGE ))
    feh --bg-scale $WALLPAPERS/${ALIST[$SHOW]}
    sleep 300
done &
#ibus-daemon -d
exec /usr/bin/dwm


The gist link is located at:
https://gist.github.com/668647

Get timestamp by rdtsc

,

On X86 processor, there is an instruction "rdtsc" to get a 64-bits width timestamp. This timestamp is set to 0 after processor reset.

  uint32_t low;
  uint32_t high;
  uint64_t retval;
  __asm__ volatile ("rdtsc\n" : "=a" (low), "=d" (high));

  retval = high;
  retval <<= 32;
  retval = retval | low;

The time-stamp value increases when processor running and processor families increment the time-stamp counter differently.

- For Pentium M processors (family [06H], models [09H, 0DH]); for Pentium 4 processors, Intel Xeon processors (family [0FH], models [00H, 01H, or 02H]); and for P6 family processors: the time-stamp counter increments with every internal processor clock cycle.

- For Pentium 4 processors, Intel Xeon processors (family [0FH], models [03H and higher]); for Intel Core Solo and Intel Core Duo processors (family [06H], model [0EH]); for the Intel Xeon processor 5100 series and Intel Core 2 Duo processors (family [06H], model [0FH]); for Intel Core 2 and Intel Xeon processors (family [06H], display_model [17H]); for Intel Atom processors (family [06H],display_model [1CH]): the time-stamp counter increments at a constant rate.That rate may be set by the maximum core-clock to bus-clock ratio of the processor or may be set by the maximum resolved frequency at which the processor is booted.

So if the timestamp increases at a constant rate, we can get the nanoseconds since processor
boot up.
#define NANOSECONDS_PER_SECOND 1000000000

uint64_t freq = 2133 * 1000000; /* host processor's frequency */

static uint64_t nanoseconds_from_tsc(void)
{
  uint32_t low;
  uint32_t high;
  uint64_t retval;
  __asm__ volatile ("rdtsc\n" : "=a" (low), "=d" (high));

  retval = high;
  retval <<= 32;
  retval = retval | low;

  return (double) retval * NANOSECONDS_PER_SECOND / freq;
}


February 2012
S M T W T F S
January 2012March 2012
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29