Sunday, August 30, 2015


At the beginning of this month I've spent a few great days in Goteborg, at GUADEC conference. That was my second GUADEC (first time I've participated last year, in Strasbourg).

There were a lot of interesting presentations, but the most I enjoyed all of the keynotes. As a Google Summer of Code student (I've worked for GStreamer project [1]), I was able to give a lightning talk about my project. It seemed to be interested to some people, so after that someone asked me to show him my project "in action". We were talking about possible improvements and new features.

In the evenings organizers prepared for attendees some event, so I could integrate with other GNOME people. Moreover, they organized for us (GSOC students and mentors) a dinner, so I could meet other students a little bit better, talk mostly about our summer projects, but also about differences in education at their universities  (people came from different part of world).

In conclusion, I enjoyed GUADEC, all presentations and evening events. I'd like to thank the GNOME Foundation for sponsoring my travel and my hostel. My participation probably wasn't be able without Foundation's help. Thanks a lot!


Monday, June 29, 2015

GStreamer Debugger - introduction

Hi everyone,
This year I've been accepted to Google Summer of Code :) Last year I worked on Banshee project [1], and this year I joined to GStreamer [2] team.
This summer I work on tool for GStreamer-based applications - GStreamer Debugger.

At the end of this summer, I'm going to provide you an application, which allows you to connect to your remote pipeline (obviously, lo interface can be used as well :)), watch pipeline graph (and its changes), spy selected queries, events, log messages, messages from bus and log messages, and even buffers. Application won't allow user modify pipeline and pipeline's state, but who knows - if it is useful feature, I implement it in the future.
GStreamer doesn't provide possibility to connect to pipeline, so I have to do it on my own.

June is a month, when I've exams on my university (fortunately, I've already passed all of them!), so I didn't spend as much time as I wanted on this project. Anyway, I accomplished a few milestones.
There's a list, what already has been done:
  • gst-trace [3] plugin, containing tcp server. For now, it sends GstEvents, GstMessages, and log messages to clients (todo: send GstBuffers, and GstQueries)
  • client application, which displays events and log messages (todo: display GstBuffers, GstQueries, GstMessages). I have a lot of ideas, how to improve client application, but I'm not sure whether I meet GSOC deadline, so I suppose, most of them will be implement after Google's program. 
  • protocol - I used Google Protobuf library [4]. In general, I've defined most of protocol's structures, I just make minor improvements, when I need it.
Below you can find a few screenshoots of client application. Full code can be found on my github account ([5], [6]).


Friday, January 2, 2015

Beefsteak with greek salad


  • 2x200g beefsteak(of ~2.5 cm thickness)
  • pepper 
  • 1/2 head of  iceberg lettuce
  • 4 tablespoons good-quality Greek extra virgin olive oil
  • 3/2 teaspoon dried oregano
  • 2 ripe tomatoes
  • 1 cucumber
  • 1 medium red onion
  • 1 jar of black olives, stoned
  • a few basil leaves
  • 200g block feta cheese
  • sea salt 


  • Greek salad
    1. Combine oil, oregano and pinch of salt.
    2. Rinse lettuce, dry it, cut it into bite and put into a salad bowl.
    3. Salt it down.
    4. Cut tomatoes into chunks.
    5. Peel a cucumber and slice.
    6. Peel an onion, and slice.
    7. Add tomatoes, cucumber, feta cheese, basil, olives and onion to a salad bowl and season with salt.
    8. Combine olive oil and oregano, and pour over the salad.
  • Beefsteak
    1. Get warm cast-iron frying pan.
    2. Oil steaks and season with salt and pepper
    3. Cook steak for 2 minutes, then turn it and cook further 2 minutes. At last, turn it again, and cook for 5-6 minutes.
  • Serve red wine (I've used medium-dry one).


 Bon appetit!

Wednesday, November 19, 2014

"Learn IT, Girl!" mentorship program just started!

This week is official beginning of "Learn IT, Girl!" program [1]. It's international program for woman, started by a few girls from Poland and Romania, invented at the Google Anita Borg Scholarship [2] retreat in 2014. A main aim is to learn by women particular programming language. Every scholar is guided by her own mentor, who helps her. Girls learn language by doing selected earlier project (which must be open-source project ofc).

I take a part in this program as a mentor, and my my mentee is Corina Teodorescu. She's from Romania and studies Marketing. Corina has decided to learn C#, and she's going to write an mobile app for phones with Android OS. Because of a lot really great ideas, she doesn't finally choose her project. She's choosing between RSS reader and application for downloading/uploading/hash-tagging images - she didn't make a decision, but I think, both are quite useful, and Corina can learn a lot by making one of them(what's the most important during this program :)

Program takes 3 months, and I believe, that would be great time for Corina and for me as well. I hope, Corina will learn a lot, and I'm going to improve my teaching skills too. We will have fun for sure :)

 Wish me and Corina luck!

Learn IT, Girl!


Tuesday, November 4, 2014

Simple macro for measuring algorithm's running time

Recently I'm spending a lot of time on my master's thesis. I'm working on algorithm for automatic number plates recognition using image segmentation. I'm trying to achieve high performance, so I need to measure execution time of my algorithms.
A few weeks ago I've written about google benchmark [1]. It's quite powerful library, and it's easy to use even in simple case, but sometimes we don't want to depend on an external library. So is it in my case too.
I've created simple macro for measuring running time:
#include <chrono>

#define MEASURE_TIME(unit, ...)    \
  [&] {         \
    using namespace std::chrono;     \
    auto start = high_resolution_clock::now ();    \
    __VA_ARGS__;       \
    auto time = high_resolution_clock::now () - start;   \
    return duration_cast<unit> (time).count ();    \
  } ();

  • unit - std::chrono::duration time interval. You can simply pass defined in standard library types, e.g. predefined types:
    • std::chrono::nanoseconds
    • std::chrono::microseconds
    • std::chrono::milliseconds
    • std::chrono::seconds
    • std::chrono::minutes
    • std::chrono::hours
  • ... - code for measurement
And example usage:
  int value = 0;

  auto duration = MEASURE_TIME(std::chrono::milliseconds, 
    int arg0, arg1;
    arg0 = run_time_consuming_algorithm ();
    arg1 = run_another_one(arg0);
    value = run_third_algorithm(arg1);

  cout << "Execution time: " << duration << std::endl
       << "Computed value: " << value;

Note, that you can use earlier declared values (value variable, in my case), because all the values are captured by reference in lambda.

Feel free to use it ;)


Wednesday, October 29, 2014

Useful (to me) post-commit hook script for checking commit message

A lot of projects are managed using bug-tracking tool (e.g. JIRA [1], Bugzilla [2], Redmine [3]), and most commits refer to a specified ticket. It's good to enter ticket number in a commit message - it allows other developers find a bug report, read more about a problem, which concern a commit.
I don't know about you, but I often forget about put it in a commit message. So I've prepared simple script, which reminds me about enter ticket message in a message. I'm using this script as a post-commit hook both at work and in my private projects.
I've pushed it to my github repository [4] (I've added also simple instruction - you can find it in a file). Feel free to use and improve it (I'm not a bash and git expert) - patches are welcome ;)

REPO_REGEX parameter

Some of my friends have asked me about REPO_REGEX parameter. So let me clarify; e.g. at work I'm using mostly company's repositories, where should I enter ticket number. But I've got also a few open source repositories, where I don't need to (sometimes even I can't, because it doesn't strongly connected with bug-reporting service) pass this number. To make my life easier, I've added this script as a global. REPO_REGEX allows me define company repositories pattern, so I don't see warning message during committing to a non-company repositories.


Monday, September 29, 2014

Tiny C++ Benchmark Framework

Lately I had to improve a little some of my algorithms. I wanted to check, how changes affect to time of algorithms execution. So I started to search benchmark framework for C++. After a while, I have found quite small, but powerful framework - google benchmark [1].

Simple usage

The simplest usage of google benchmark is shown below:
#include <benchmark/benchmark.h>
#include <algorithm>

int complex_computation(int n)
  if (n == 0) 
    return 0;

  unsigned int a = 1, b = 1;

  for (unsigned int i=0; i < n-1; i++) 
      std::swap(a, b);
      b += a;

  return b;

static void BM_Fibonacci(benchmark::State& state)
  int ret;

  while (state.KeepRunning())
    ret |= complex_computation(500);

  CHECK(ret != 0);


int main(int argc, const char* argv[]) 
  benchmark::Initialize(&argc, argv);

  return 0;
At the beginning, we have to define function, which will be measured (complex_computation, in my case). Next, we're defining benchmark method - BM_Fibonacci. It has one argument - state (I will talk about it later). In while loop we call our method, until benchmark's working. ret variable is used only because of compiler optimizations (we'd like to avoid removing dummy code). Benchmark method should be later registered (using BENCHMARK macro). In main function, framework should be initialized, and after that, we can run all our benchmark methods.
loganek@hf-gcs-computer:~/Documents/blog-benchmark$ g++ benchmark.cpp -std=c++11 -lbenchmark -lpthread -O2 -o benchmark
loganek@hf-gcs-computer:~/Documents/blog-benchmark$ ./benchmark 
Reading /proc/self/cputime_ns failed. Using getrusage().
Benchmarking on 4 X 2701 MHz CPUs
CPU scaling is enabled: Benchmark timings may be noisy.
DEBUG: Benchmark      Time(ns)    CPU(ns) Iterations
DEBUG: BM_Fibonacci        208        225    2222788                                  

As you can see, there is computation time, cpu and iterations count - everything what we need :) Moreover, we can also get a few informations about machine.

Arguments, range of arguments

Snippet shown above is very simple, but this framework offers users much more. We can define a set of arguments for benchmark. Let's remind previous example. We tried to measure fibonacci implementation. But I hardcoded an argument. Sometimes we'd like to measure one method with different arguments. We don't have to define BM_Fibonacci_5, BM_Fibonacci_42, BM_Fibonacci_87 functions for different arguments. Let's look at the improvement of previous code:
static void BM_Fibonacci(benchmark::State& state)
  int ret;
  while (state.KeepRunning())
    ret |= complex_computation(state.range_x());
  CHECK(ret != 0);

and the output is also quite different:
loganek@hf-gcs-computer:~/Documents/blog-benchmark$ ./benchmark 
Reading /proc/self/cputime_ns failed. Using getrusage().
Benchmarking on 4 X 2701 MHz CPUs
CPU scaling is enabled: Benchmark timings may be noisy.
DEBUG: Benchmark         Time(ns)    CPU(ns) Iterations
DEBUG: BM_Fibonacci/5           3         19   25832109                                  
DEBUG: BM_Fibonacci/42         18         35   14398500                                  
DEBUG: BM_Fibonacci/87         44         61    8224413   
We've access for results of every argument, which I passed to a benchmark method.
It is also possible to pass range of arguments to our benchmark method.
BENCHMARK(BM_Fibonacci)->Range(0, 1024);
Defined range runs benchmark for min, max in this range, and every power of 8 from this range. So in my case: 0, 1, 8, 64, 512 and 1024.

Multithreading, other features

Google Benchmark framework gives a few other features for developers:
  • multithreading
  • benchmark templates
  • pair of arguments
  • custom reporter class
You may see usage of other features in google benchmark example code [2] or on README page[3].


That's one of first test framework, which I used for now. Previously I wrote simple methods for measurements, but it wasn't so convenient, and in the long run, it's just waste of time. Moreover, benchmark helps me keep in order my tests, so my code is much cleaner than before.
In the future, I'd like to check also other frameworks; I heard about Celero [4] and hayai [5]. But for now, google benchmark fits my needs.