Archive for the ‘Uncategorized’ Category

Displaying an SVG file using Cairo (librsvgmm + cairomm)

September 12, 2009

Although Cairo and SVG seems like a natural partnership to me, I had trouble finding any information about displaying SVG files using Cairo. The following are the steps I followed to display an SVG file in Cairo using the C++ bindings – the steps should, however, be similar for the C or Python bindings.

Source code is available from SVN: http://vero-layout.googlecode.com/svn/trunk/background/svg_cairo_example

Step 1: Download librsvgmm (C++ bindings for librsvg) from http://ftp.gnome.org/pub/GNOME/sources/librsvgmm/2.26/

Step 2: Unarchive the files and run “sudo ./configure && make && make install” to install the libraries.

Step 3: Run “sudo ldconfig” to update your shared library linking.

Step 4: Download the source code and run “make all” to build the projects. The source is small and self explanatory – a quick read through will be enough to show you how to use the bindings.

Step 5: Run the program (“./svg”). The program will load the tux.svg file and display it in a GTK window. Too easy!

SVG Cairo Example

Automarker Feature Request

October 24, 2008

Remark 1 test case for all previous submissions (to fix a single test case later on). Totally needed that tonight, darn.

Mutat(e?) specs.

October 15, 2008

Mutat = Tatum backwards = COMP2304 automarking backend. 

Marking requirements 

 

  • Test cases and meta data are explicitely registered. A hash? of the file is taken. If the file changes between now and when other tests are run then notify the user so that they can re-register it. Once registered, all test case info is retrieved from database rather than files, so that accidently modified files do not harm future marking.
  • If test cases are re-registered then any marking that has already been done must be redone. Penalties must be preserved. Only the most recent submission within each resubmission category is marked. Multiple resubmissions are marked and the highest result is associated with the student. Files must be archived in order to ensure that the correct copy of the students code is marked. 
    (This has to be super easy. Changing a test case and ensuring good update results is critical).
  • Marking can be haph-hazard 
  1. Mark bulk of submissions when they arrive. 
  2. Mark some other students code when he hands it in late without penalty. Mark the late submissions with penalties. 
  3. Mark resubmissions (again in several batches).
  4.  Remark a file for ONE STUDENT who has ALREADY SUBMITTED (but perhaps submitted the wrong copy) and CONFIRM before replacing their result. 
  5. Do not let a student submit multiple times without confirmation from a tutor. 
  • A system for  applying penalties for late submission and resubmission so that those penalties can be lifted by tutors. The penalty state must somehow? be mirrored on the live server without being killed by the development server.
  • Mark assignments without any danger of hurting previous ones.
  • Automatic database backup so I can stop using a development and live server. If assignments are re-marked several times due to faulty test cases it should be OK.
Usability requirements
  • Too many command line arguments – run through a simple GUI to ensure all arguments are correct.
  • Progress bar
  • Compile and run each assignment as it goes – no need to compile all first and then find a bug in the running code.
  • Ability to resume – if I have marked 50% of assignments do I need to remark them all if one piece of code critical crashes (assuming I have not modified the automarker source or test cases in between – if modified force the ENTIRE GROUP to be marked again – including any previous submissions).
  • Reduce the dependence on additional script files (db2csv and dbsync in particular). 
Mark security requirements
  • The state of the OFFICIAL marks .csv files should ALWAYS EXACTLY mirror the results stored in the databases. 
  • Should not be able to directly edit the .csv file (because then database will not reflect changes)
Time requirements
  • < 30 minutes 
Test case requirements
  • Minimal new work to write a test case i.e. copy meta data and edit code.
  • Must be header guard safe (i.e. not cause any NEW linking errors that students would not have found when carefully including header files in exactly the right places).
  • Written in native C++ so that all functionality can be tested.
  • Can only award full (true) or none (false) marks to make writing tests easier.
  • Should all be contained within one file.
  • If possible perhaps students should be able to view the code which is being used to test their code? This is good for openness (especially if automarker is open source).
  • Most lenience possible i.e. do not fail if student forgot to hand in one file or failed to implemented one function – run all tests that do not use that function.
Security of marker
  • Prevent infinite loops
  • Handle crashes nicely
  • Prevent? disk writes?
  • Do not let students know critical directories to write to if they see the automarker source i.e. do not hard code the results database name and login!
Student testbed
  • Allow students to test all their files for the assignment against a core set of example test cases. For each test case inform them of what was being tested, if they passed or failed, and why. 
  • Ability to run a subset of tests?
  • Shoud? run WITHOUT the benfit of python
  • IF THE AUTOMARKER IS OPEN SOURCE AND SOME OF IT IS IN PYTHON AND PYTHON IS ON THE UNI COMPUTERS THEN CAN WE USE PYTHON? IF OPEN SOURCE WE DO NOT CARE IF STUDENTS SEE THE CODE! THIS COULD SAVE A LOT OF EFFORT.
  • Should compile files, inject code, and run the minimum set of tests.
  • Ideally the smallest possible set of files 
  1. A minimal python script – no database – possibly with a GUI
  2. An interface between python and dlls (converter.exe?)
  3. The list of test cases? If open source, again, does not matter if these are visible. I love openness and honesty.
  4. I would like people to write their own test functions in their main etc – will this discourage them? or will they perhaps simply learn to write them as part of this new file. 
  5. At least ensures that they meet the minimum standards defined by the examples in the assignments (no silly errors like extra whitespace)
  • This means that when writing the python script I should modularize it in to core functions (given to students) and logging functions etc (the database and statistics code) -> database information displayed to stdout. I would rather not have a common class structure one which does database and one which does stdout because I tried this before and it was super annoying to maintain in python (no enforced class structure)
Web Interface (Tatum)
  • Alternative to test exe given to students.
  • Essentially the test exe accessable through a web interface
  • Decorate the exe with enough CGI methods to make it accessable through a web interface. 
  • Ability to write test cases – some sort of intermediate language would be nice but makes testing of the full C++ range of ideas (templtaes exceptions etc) would be nice but I think that normal C++ is probably the best bet.
  • I really want people writing their own test functions.
In order to address all these issues I am going to need to write the automarker from scratch, identifying the minimal requirements models and double tripple checking that my database schema supports all the operations I would like. 

Compile times for COMP2304 Assignment 3

October 14, 2008

Graph of compilation times for 25 test cases per student, 200 students. First bar shows compilation against Boost Library which was an interesting experiment, and will be used in part in Automarker v3, but which I would never use again as the core testing method because exporting certain things (i.e. pass by pointer) is impossible.

 

Second option is compilation of the same code without boost. This still takes 1.2 hours which just isn’t practicle if you need to be able to remark an entire class often.

 

Third option is time taken if each file needs only be compiled once (3 minutes). This is a huge speed increase (25 x vs 5x for not using boost) so I’ll be concentrating my efforts on working on an efficient and automated way of determining code dependencies and compiling a file a minimum number of times.

One idea is to automatically decorate all the functions and classes in a file with dllspec instructions and then dynamically call them. If an error occurs then the student did not provide the method. This will obviously only work on windows. Unfortunately this won’t work with templates.

 

In fact, the only thing that will work with templates is injecting code directly into the students code before compiling.

 

Another idea is to start by compiling against all test cases and then if the students code does not compile, try compiling all 25 test cases seperately. To fit in a coherent system this would end with a single compilation against the N test cases which succesfully compiled before.  On average I would exepect 30% of students to submit incomplete solutions which would give a runtime of 25 minutes. Closer to acceptable but still not fantastic.

 

An ideal solution would identify exactly which test cases each student could compile against and only compile these ones. This would require:

  1.  A way to identify what a given test method depends upon – this can get tricky for things like templates
  2. A way to identify what the student has implemented. Could use regex but this almost requires implementing an entire C++ parser because of the huge number of ways there are to implement a function etc. For example, given a constructor, they may have declared it inline or outline. If the latter, you have to find both a prototype and implementation. I’m sure there are worse scenarios.
The final option is to enfoce a complete solution from each student so that it will at least compile. We can tell students that they must implement all prototype, but at least some will spell them incorrectly. Alternately we can provide a header file (this was done when I completed the course) but I believe that this means that the student won’t learn to write a header file themselves (it was certainly the case with some of the people who did the course with me). 

 

 

I’m not really sure where this leaves me. Let me know if you have any ideas! 

Scholarly PDF

September 2, 2008

It would be great to allow PDFs to be extended with plugins. One idea I had would be to embed citation data in to the PDF of journal articles, so when you go back to do referencing it isn’t such a massive pain.

Protobots gears.

August 25, 2008

Eagle to Protel

August 15, 2008

http://www.dutchforce.com/~eforum/index.php?s=fce0f1b0b1b3c7f0649e9962019f19cc&showtopic=14670

Untested.

Thesis seminar

August 15, 2008

Note to self: Force team project students to come to half time thesis seminar. Their feedback on the proposed features of the Atmel simulator will be very helpful.

C++ bottlenecks.

August 15, 2008

While trying to do some speed testing of C++ for my thesis:


int answer = 0;

for (int i = 0; i != 1000000000; ) {
    answer = ((answer + i++) * 10);
    //answer += i
    //answer *= 2;
    //answer = answer % 65535;
}


Beware memory allocation:

  • delete takes longer than new.
  • BUT memory leaks slow your program execution exponentially as your memory becomes fragmented

Beware non-trivial operators:

  • Using modulo slowed execution by an ENTIRE ORDER OF MAGNITUDE.

Beware data types:

  • I used long long for answer instead of int because some of my code demands the use of large integers. This also slowed execution by an order of magnitude, presumably because it was compiled in 32 bit mode and had to do multiple register copies for every operation.
  • I’ll be reviewing my requirements to try and remove dependency on long long in time critical code!

How to wire up a MAX232

August 13, 2008

This is how you wire up a MAX232 to a picaxe cable.

MAX232 Schematic