Friday, November 27, 2015

MSDOS applications run with pause on exit

I have a shortcut to a .BAT file (or any kind of DOS application). I need after its execution, DOS window not to close until i read the output of the program(s).

Adding a line with pause in the end of file is not an option (my file stays in VCS).

Solution: You could change the command of shortcut from this:


to this:

c:\path\shortcut.bat & pause

You will get an message "Press any key to continue" and you will read the output of the program.

Thursday, November 26, 2015

Best shortcuts for IntelliJ Idea

Open class by name Ctrl + N
Show members Ctrl+F12
Go to implementation Ctrl + Alt + B
Open file by name Ctrl + Shift + N
Jump to next/prev cursor position Alt + left/right arrow
Show in Project Alt + F1 + Enter

Wednesday, November 25, 2015

Install Java JDK/JRE on Debian jessie with 'apt-get install'

Issue: default JDK for Debian 8 is JDK 7. I need a maintainable way to upgrade it to JDK 8.


1. Edin file /etc/apt/sources.list and add this line on the bottom:
deb jessie-backports main

2. sudo apt-get update

3. sudo apt-get install openjdk-8-jdk

4. test it as this:
java -version

If the result shows version 7, you could check the names of JDK7 packages and remove them
4.1. Check older JDK packages:
dpkg -l | grep openjdk

4.2. Remove your older JDK packages, e.g.:
apt-get purge openjdk-7-jdk
apt-get purge openjdk-7-jre
apt-get purge openjdk-7-jre-headless


Tuesday, November 24, 2015

JAMon - nice and simple java monitor for measuring code performance in Java

General information

Official site:
A SourceForge project

Maven dependency

Place in pom.xml:

Example 1


import com.jamonapi.*;

public class MonitorTest {
    public static void main(String[] args) throws Exception {
        Monitor mon=null;
        for (int i=1; i<=10; i++) {
            mon = MonitorFactory.start("myFirstMonitor");
        System.out.println(mon);  // toString() method called

Example 2

Tuesday, November 10, 2015

Размишления за DDR паметта - DDR1, DDR2, DDR3, DDR4

Базова честота и ефективна честота

DDR паметта (ddr1, ddr2, ddr3, ddr4) има базова честота и ефективна честота. Ефективната честота е двойно по-голяма от базовата. При ddr2-800, базовата е 400MHz. Това са теоретично 3200 МБ/с. Но при DDR2-800 се постигат теоретични 6400 МБ/с.

От къде идва удвояването? 

При по-простия подход (SDR) паметта предава 1 бит информация за един пълен цикъл. При DDR паметта може да се предадат два бита информация.
Формулата за пропусквателната способност е следната:

пропусквателната способност = реална честота * ширина на шината в битове * брой пренасяни битове за цикъл

Например за DDR2-800 имаме 400 MHz * 64 бита * 2 бита; 64 бита са 8 байта. Това са ефективни 6400МБ/с, което е ефективни 800 MHz. Това важи за всяка памет DDR2-800 и е аналогично за останалите честоти.

Неофициално максимална памет

За IBM/Lenovo ThinkPad -


Тук може да намерите евтина DDR2 DDR2-800 памет за AMD процесори на добра цена.
Разширена съвместимост с:
Asus M2N-E
Asus m4n78 Pro - с последен BIOS се поддържат 4 GB-тови модули, но само 2. Ако скожите 3 или 4, почва да дава проблеми, все едно модулите или слотовете са дефектни.

Thursday, November 5, 2015

Java: Poor performance of Files.newDirectoryStream() with wildcards

Here are results of comparison of getting single result of Files.newDirectoryStream() and File.exists().

Wildcards pattern I used is "prefix_prefix_prefix____?.tmp". Results are almost the same when calling Files.newDirectoryStream() with string argument with no wildcard (direct match).

Test results 1:

measure exists speed in loop 1000 times - BEGIN
measure exists speed in loop 1000 times - END
Elapsed: 5 ms

Test results 2:

measure wildcards match speed in loop 1000 times - BEGIN
measure wildcards match speed in loop 1000 times - END
Elapsed: 80590 ms

Test environment:

Windows 7 system
NTFS system
Folder with 90 000 files (zero length)
Java 8

dir approach

I looped this MSDOS command for 1000 times to check performance of dir with wildcards:

dir prefix_prefix_prefix____*.tmp

I tested it in loop with:
FOR /L %i IN (1,1,1000) DO @dir prefix_prefix_prefix____*.tmp > nul

It finished in about 1000ms. I suppose this time is spend mainly in calling DIR command by command interpreter.


Files.newDirectoryStream() has absolutely no performance optimizations when working with wildcards.

Relative information

File.list also has poor performance

Source code of newDirectoryStream

    public static DirectoryStream<Path> newDirectoryStream(Path dir, String glob)
        throws IOException
        // avoid creating a matcher if all entries are required.
        if (glob.equals("*"))
            return newDirectoryStream(dir);

        // create a matcher and return a filter that uses it.
        FileSystem fs = dir.getFileSystem();
        final PathMatcher matcher = fs.getPathMatcher("glob:" + glob);
        DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() {
            public boolean accept(Path entry)  {
                return matcher.matches(entry.getFileName());
        return fs.provider().newDirectoryStream(dir, filter);