<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.visual-prolog.com/index.php?action=history&amp;feed=atom&amp;title=Execution_Speed_%28compare_to_C%2B%2B%29</id>
	<title>Execution Speed (compare to C++) - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.visual-prolog.com/index.php?action=history&amp;feed=atom&amp;title=Execution_Speed_%28compare_to_C%2B%2B%29"/>
	<link rel="alternate" type="text/html" href="https://wiki.visual-prolog.com/index.php?title=Execution_Speed_(compare_to_C%2B%2B)&amp;action=history"/>
	<updated>2026-04-13T01:19:17Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://wiki.visual-prolog.com/index.php?title=Execution_Speed_(compare_to_C%2B%2B)&amp;diff=1490&amp;oldid=prev</id>
		<title>Thomas Linder Puls: Categorized</title>
		<link rel="alternate" type="text/html" href="https://wiki.visual-prolog.com/index.php?title=Execution_Speed_(compare_to_C%2B%2B)&amp;diff=1490&amp;oldid=prev"/>
		<updated>2008-10-29T20:35:12Z</updated>

		<summary type="html">&lt;p&gt;Categorized&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 22:35, 29 October 2008&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l114&quot;&gt;Line 114:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 114:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So this Visual Prolog program though significantly slower than the optimized C++ program is however closer to the optimized C++ program than to the un-optimized C++ program.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;So this Visual Prolog program though significantly slower than the optimized C++ program is however closer to the optimized C++ program than to the un-optimized C++ program.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Basic Information]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Thomas Linder Puls</name></author>
	</entry>
	<entry>
		<id>https://wiki.visual-prolog.com/index.php?title=Execution_Speed_(compare_to_C%2B%2B)&amp;diff=1443&amp;oldid=prev</id>
		<title>Thomas Linder Puls: Initial</title>
		<link rel="alternate" type="text/html" href="https://wiki.visual-prolog.com/index.php?title=Execution_Speed_(compare_to_C%2B%2B)&amp;diff=1443&amp;oldid=prev"/>
		<updated>2008-10-28T00:32:46Z</updated>

		<summary type="html">&lt;p&gt;Initial&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;It is not completely trivial to compare the execution speed of different programming languages, because some problems may suit one language better than another.  Nevertheless such comparison is interesting.&lt;br /&gt;
&lt;br /&gt;
This article describes a little simple comparison of Visual Prolog and Microsoft C++.  The comparison does not claim any scientific accuracy; it is just supposed to give an indication.&lt;br /&gt;
&lt;br /&gt;
The classical Towers of Hanoi problem is used for the test, the actual writing of the result to the standard output stream is skipped, because otherwise the test take nearly the same time because all the time is spend in drawing and scrolling the console window.&lt;br /&gt;
&lt;br /&gt;
The test is carried out with Visual Prolog 7.2 and Microsoft C++ (Visual Studio 2005).&lt;br /&gt;
&lt;br /&gt;
=== Visual Prolog run ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;vip&amp;gt;class main&lt;br /&gt;
predicates&lt;br /&gt;
    run : core::runnable.&lt;br /&gt;
end class main&lt;br /&gt;
&lt;br /&gt;
implement main&lt;br /&gt;
&lt;br /&gt;
clauses&lt;br /&gt;
    run():-&lt;br /&gt;
        console::init(),&lt;br /&gt;
        profileTime::init(),&lt;br /&gt;
        profileTime::start_pr(&amp;quot;hanoi&amp;quot;),&lt;br /&gt;
        hanoi(25, &amp;quot;a&amp;quot;, &amp;quot;b&amp;quot;, &amp;quot;c&amp;quot;),&lt;br /&gt;
        profileTime::stop_pr(&amp;quot;hanoi&amp;quot;),&lt;br /&gt;
        profileTime::printAndReset(stdio::getOutputStream()).&lt;br /&gt;
&lt;br /&gt;
class predicates&lt;br /&gt;
    hanoi : (positive N, string SourcePole, string AuxPole, string TargetPole).&lt;br /&gt;
clauses&lt;br /&gt;
    hanoi(0, _SourcePole, _AuxPole, _TargetPole) :-&lt;br /&gt;
        !.&lt;br /&gt;
    hanoi(N, SourcePole, AuxPole, TargetPole) :-&lt;br /&gt;
        hanoi(N-1, SourcePole, TargetPole, AuxPole),&lt;br /&gt;
        /* stdio::writef(&amp;quot;Move from % to %\n&amp;quot;, SourePole, TargetPole),*/&lt;br /&gt;
        hanoi(N-1, AuxPole, SourcePole, TargetPole).&lt;br /&gt;
&lt;br /&gt;
end implement main&lt;br /&gt;
&lt;br /&gt;
goal&lt;br /&gt;
    mainExe::run(main::run).&amp;lt;/vip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result was this &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Steps = 134217727&lt;br /&gt;
&lt;br /&gt;
|  Predicate        | Calls |   AvgNet   |   Netto    |   Average  |    Total  |&lt;br /&gt;
+-------------------+-------+------------+------------+------------+-----------+&lt;br /&gt;
| hanoi             |     1 |  5.6989841 |   5.698984 |   5.698984 |   5.698984|&lt;br /&gt;
+-------------------+-------+------------+------------+------------+-----------+&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== C++ run ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;#include &amp;quot;stdafx.h&amp;quot;&lt;br /&gt;
&lt;br /&gt;
typedef wchar_t* string;&lt;br /&gt;
&lt;br /&gt;
static int steps = 0;&lt;br /&gt;
&lt;br /&gt;
void hanoi(int N, string A, string B, string C)&lt;br /&gt;
{&lt;br /&gt;
    if (N &amp;gt; 0)&lt;br /&gt;
    {&lt;br /&gt;
        hanoi(N-1, A, C, B);&lt;br /&gt;
        // move a disk from A to C&lt;br /&gt;
        steps++;&lt;br /&gt;
        hanoi(N-1, B, C, A);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
int _tmain(int argc, _TCHAR* argv[])&lt;br /&gt;
{&lt;br /&gt;
    clock_t start = clock();&lt;br /&gt;
    hanoi(27, L&amp;quot;left&amp;quot;, L&amp;quot;middle&amp;quot;, L&amp;quot;right&amp;quot;);&lt;br /&gt;
    clock_t finish = clock();&lt;br /&gt;
    wprintf(L&amp;quot;Steps = %d\n&amp;quot;, steps);&lt;br /&gt;
    double elapsed_time = (finish - start) / 1000.0;&lt;br /&gt;
    printf( &amp;quot;\nProgram takes %.2f seconds.\n&amp;quot;, elapsed_time );&lt;br /&gt;
    return 0;&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In &amp;#039;&amp;#039;&amp;#039;Debug&amp;#039;&amp;#039;&amp;#039; mode this program produced: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Steps = 134217727&lt;br /&gt;
&lt;br /&gt;
Program takes 38.45 seconds.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In &amp;#039;&amp;#039;&amp;#039;Release&amp;#039;&amp;#039;&amp;#039; mode it produced:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Steps = 134217727&lt;br /&gt;
&lt;br /&gt;
Program takes 1.95 seconds.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Summary ===&lt;br /&gt;
&lt;br /&gt;
{| {{prettytable}}&lt;br /&gt;
! Test&lt;br /&gt;
! Time&lt;br /&gt;
! Relative&lt;br /&gt;
|-&lt;br /&gt;
| C++ Debug&lt;br /&gt;
| 38.45 sec&lt;br /&gt;
| 675%&lt;br /&gt;
|-&lt;br /&gt;
| Visual Prolog&lt;br /&gt;
| 5.70 sec&lt;br /&gt;
| 100%&lt;br /&gt;
|-&lt;br /&gt;
| C++ Release&lt;br /&gt;
| 1.95 sec&lt;br /&gt;
| 34%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
So the Release version of the C++ program is around 3 times faster than the Visual Prolog program which is 6.75 times faster than the Debug version of the C++ program.&lt;br /&gt;
&lt;br /&gt;
So this Visual Prolog program though significantly slower than the optimized C++ program is however closer to the optimized C++ program than to the un-optimized C++ program.&lt;/div&gt;</summary>
		<author><name>Thomas Linder Puls</name></author>
	</entry>
</feed>