Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #97025 > unrolled thread

Can any assembly programmers here give me a time estimate to write a database routine?

Started byDFS <nospam@dfs.com>
First post2016-11-19 13:49 -0500
Last post2016-11-19 13:54 -0800
Articles 20 on this page of 24 — 8 participants

Back to article view | Back to comp.lang.c


Contents

  Can any assembly programmers here give me a time estimate to write a database routine? DFS <nospam@dfs.com> - 2016-11-19 13:49 -0500
    Re: Can any assembly programmers here give me a time estimate to write a database routine? "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-19 14:10 -0500
      Re: Can any assembly programmers here give me a time estimate to write a database routine? "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-19 14:42 -0500
    Re: Can any assembly programmers here give me a time estimate to write a database routine? BartC <bc@freeuk.com> - 2016-11-19 19:34 +0000
      Re: Can any assembly programmers here give me a time estimate to write a database routine? Melzzzzz <mel@zzzzz.com> - 2016-11-19 21:25 +0100
        Re: Can any assembly programmers here give me a time estimate to write a database routine? jacobnavia <jacob@jacob.remcomp.fr> - 2016-11-19 23:00 +0100
    Re: Can any assembly programmers here give me a time estimate to write a database routine? jacobnavia <jacob@jacob.remcomp.fr> - 2016-11-19 21:13 +0100
      Re: Can any assembly programmers here give me a time estimate to write a database routine? DFS <nospam@dfs.com> - 2016-11-19 23:01 -0500
        Re: Can any assembly programmers here give me a time estimate to write a database routine? jacobnavia <jacob@jacob.remcomp.fr> - 2016-11-20 11:43 +0100
        Re: Can any assembly programmers here give me a time estimate to write a database routine? jacobnavia <jacob@jacob.remcomp.fr> - 2016-11-20 11:44 +0100
          Re: Can any assembly programmers here give me a time estimate to write a database routine? DFS <nospam@dfs.com> - 2016-11-20 08:36 -0500
            Re: Can any assembly programmers here give me a time estimate to write a database routine? "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-20 10:29 -0500
              Re: Can any assembly programmers here give me a time estimate to write a database routine? jacobnavia <jacob@jacob.remcomp.fr> - 2016-11-20 16:40 +0100
        Re: Can any assembly programmers here give me a time estimate to write a database routine? jacobnavia <jacob@jacob.remcomp.fr> - 2016-11-20 11:45 +0100
        Re: Can any assembly programmers here give me a time estimate to write a database routine? jacobnavia <jacob@jacob.remcomp.fr> - 2016-11-20 11:46 +0100
        Re: Can any assembly programmers here give me a time estimate to write a database routine? BartC <bc@freeuk.com> - 2016-11-20 11:49 +0000
    Re: Can any assembly programmers here give me a time estimate to write a database routine? Noob <root@127.0.0.1> - 2016-11-19 21:23 +0100
      Re: Can any assembly programmers here give me a time estimate to write a database routine? "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-19 15:58 -0500
        Re: Can any assembly programmers here give me a time estimate to write a database routine? Robert Spanjaard <spamtrap@arumes.com> - 2016-11-20 00:26 +0100
          [OT] blueberry muffins "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-19 18:40 -0500
            Re: [OT] blueberry muffins Robert Spanjaard <spamtrap@arumes.com> - 2016-11-20 00:51 +0100
              Re: [OT] blueberry muffins "James R. Kuyper" <jameskuyper@verizon.net> - 2016-11-19 19:05 -0500
                Re: [OT] blueberry muffins Robert Spanjaard <spamtrap@arumes.com> - 2016-11-20 01:29 +0100
    Re: Can any assembly programmers here give me a time estimate to write a database routine? "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2016-11-19 13:54 -0800

Page 1 of 2  [1] 2  Next page →


#97025 — Can any assembly programmers here give me a time estimate to write a database routine?

FromDFS <nospam@dfs.com>
Date2016-11-19 13:49 -0500
SubjectCan any assembly programmers here give me a time estimate to write a database routine?
Message-ID<o0q6q9$jgs$2@dont-email.me>
I can't find any active assembly groups to post this to, so I figured 
I'd take a shot here.



My short python program below summarizes a SQLite database.

How long do you think this would take to do in assembler?

And I would want to replicate all functionality, including the timer and 
the output format.

Thanks


##########################################################################
import os, sqlite3, time

startTime = time.clock()

#DATABASE/CONNECTIONS
dbName = "D:\python\my_programs\Usenet\USENET.sqlite"
conn   = sqlite3.connect(dbName)
conn.text_factory = str
db     = conn.cursor()

#NAME OF DB FILE
print "Source file:", dbName

#SQLITE VERSION
db.execute('SELECT SQLITE_VERSION()')
print "SQLite version: %s" % db.fetchone()
print

#LIST OF TABLES
cSQL = "SELECT name FROM sqlite_master "
cSQL += "WHERE type  = 'table' "
cSQL += "AND   name != 'sqlite_sequence' "
cSQL += "ORDER BY name;"
db.execute(cSQL)
tblNames = db.fetchall()
tblCnt = len(tblNames)

#COUNT ROWS, FOREIGN KEYS, INDEXES, COLUMNS
rows,maxrows  = 0,0
forkeys,indexes,cols = 0,0,0
cntInts,cntText = 0,0

for tblName in tblNames:
     db.execute('SELECT COUNT(*) FROM ' + str(tblName[0]) + '')
     tblRows = db.fetchone()[0]
     maxrows = tblRows if tblRows > maxrows else maxrows
     rows += tblRows

     db.execute('PRAGMA foreign_key_list(' + str(tblName[0]) + ')')
     forkeys+=len(db.fetchall())

     db.execute('PRAGMA index_list(' + str(tblName[0]) + ')')
     indexes+=len(db.fetchall())

     db.execute('PRAGMA table_info(' + str(tblName[0]) + ')')
     for info in db.fetchall():
         if info[2] == 'INTEGER' or info[2] == 'INT': cntInts+=1
         if info[2] == 'TEXT': cntText+=1
         cols+=1


# SUMMARY
print "{:,}".format(rows), "rows"
print tblCnt,"tables (max row = " + "{:,}".format(maxrows) + ")"
print cols,"columns"
print '  integer:', cntInts
print '     text:', cntText
print '%s indexes (%s foreign keys)' % (indexes,forkeys)
print "{:,}".format(os.path.getsize(dbName)), "bytes on disk"
print

#TIMER
endTime = time.clock()
print "Time: %.2g seconds" %(endTime-startTime)

#CLOSE
db.close()
conn.close()
##########################################################################



$ python sqlite_summary.py

Source file: D:\python\my_programs\Usenet\USENET.sqlite
SQLite version: 3.8.11

22,390,013 rows
13 tables (max row = 17,874,951)
52 columns
   integer: 30
      text: 22
22 indexes (7 foreign keys)
3,500,213,248 bytes on disk

Time: 1.2 seconds

[toc] | [next] | [standalone]


#97027

From"James R. Kuyper" <jameskuyper@verizon.net>
Date2016-11-19 14:10 -0500
Message-ID<b627e47b-512e-f264-5cc2-e9465ddc0264@verizon.net>
In reply to#97025
On 11/19/2016 01:49 PM, DFS wrote:
> I can't find any active assembly groups to post this to, so I figured
> I'd take a shot here.
>
>
> My short python program below summarizes a SQLite database.

Since your program is in python, a python forum would probably have been 
a better place to start.

> How long do you think this would take to do in assembler?

I'm not qualified to answer your question, but I can tell you that you 
need to specify which assembler you want it converted to. See 
<https://en.wikipedia.org/wiki/Comparison_of_assemblers> for a list you 
can choose from.

That ties in to the topicality issue - if you just look for newsgroups 
with "assembl" in the name, you're not likely to find what you want. If 
you open up your search to include other kinds of forums, and narrow 
your search to the particular assembler you're interested in, you're 
more likely to find someone able to give you a good answer to your question.

[toc] | [prev] | [next] | [standalone]


#97031

From"James R. Kuyper" <jameskuyper@verizon.net>
Date2016-11-19 14:42 -0500
Message-ID<1ae6bd45-8c8e-ecbc-4461-71198ef6aa96@verizon.net>
In reply to#97027
On 11/19/2016 02:10 PM, James R. Kuyper wrote:
...
> with "assembl" in the name, you're not likely to find what you want. If
> you open up your search to include other kinds of forums, and narrow
> your search to the particular assembler you're interested in, you're
> more likely to find someone able to give you a good answer to your question.

For example - if you want it translated into ML64, this seems to be a 
fairly active forum: 
<http://masm32.com/board/index.php?PHPSESSID=34f0e2330a896490048be75becd89d5d&board=53.0>

[toc] | [prev] | [next] | [standalone]


#97029

FromBartC <bc@freeuk.com>
Date2016-11-19 19:34 +0000
Message-ID<o0q9fc$uhk$1@dont-email.me>
In reply to#97025
On 19/11/2016 18:49, DFS wrote:
> I can't find any active assembly groups to post this to, so I figured
> I'd take a shot here.

comp.lang.asm.x86 is still active (I thought you posted there already 
but that's someone called DSF).

I doubt it would help though as this is quite high level stuff; it would 
be challenging to do it even in C.

How many weeks have you got just to attempt this:

 > print "{:,}".format(os.path.getsize(dbName)), "bytes on disk"

Assuming you just want to talk to SQL rather than implement it, you 
might be better off finding a C program that does things along the same 
lines. That will be easier to port to ASM.

> My short python program below summarizes a SQLite database.
>
> How long do you think this would take to do in assembler?
>
> And I would want to replicate all functionality, including the timer and
> the output format.

Explaining why would help people give you better answers.

You probably already know that an ASM program is usually written for a 
particular processor on a specific platform so is not readily portable.

-- 
Bartc

[toc] | [prev] | [next] | [standalone]


#97037

FromMelzzzzz <mel@zzzzz.com>
Date2016-11-19 21:25 +0100
Message-ID<20161119212538.6d1b2bae@maxa-pc>
In reply to#97029
On Sat, 19 Nov 2016 19:34:35 +0000
BartC <bc@freeuk.com> wrote:

> On 19/11/2016 18:49, DFS wrote:
> > I can't find any active assembly groups to post this to, so I
> > figured I'd take a shot here.  
> 
> comp.lang.asm.x86 is still active (I thought you posted there already 
> but that's someone called DSF).
> 
> I doubt it would help though as this is quite high level stuff; it
> would be challenging to do it even in C.

Nope, it's just function calls. Given simplicity of sqlite C interface
I would say one to two hours needed.

> 
> How many weeks have you got just to attempt this:
> 
>  > print "{:,}".format(os.path.getsize(dbName)), "bytes on disk"  

stat?




-- 
press any key to continue or any other to quit

[toc] | [prev] | [next] | [standalone]


#97048

Fromjacobnavia <jacob@jacob.remcomp.fr>
Date2016-11-19 23:00 +0100
Message-ID<o0qhvu$488$1@dont-email.me>
In reply to#97037
Le 19/11/2016 à 21:25, Melzzzzz a écrit :
> On Sat, 19 Nov 2016 19:34:35 +0000
> BartC <bc@freeuk.com> wrote:
>
>> On 19/11/2016 18:49, DFS wrote:
>>> I can't find any active assembly groups to post this to, so I
>>> figured I'd take a shot here.
>>
>> comp.lang.asm.x86 is still active (I thought you posted there already
>> but that's someone called DSF).
>>
>> I doubt it would help though as this is quite high level stuff; it
>> would be challenging to do it even in C.
>
> Nope, it's just function calls. Given simplicity of sqlite C interface
> I would say one to two hours needed.
>

Yes, it is not a big deal. But that brings nothing what speed is 
concerned since SQLite is VERY slow.
>>
>> How many weeks have you got just to attempt this:
>>
>>  > print "{:,}".format(os.path.getsize(dbName)), "bytes on disk"
>
> stat?
>

And printf, with a %lld format.

But what for?

[toc] | [prev] | [next] | [standalone]


#97034

Fromjacobnavia <jacob@jacob.remcomp.fr>
Date2016-11-19 21:13 +0100
Message-ID<o0qbos$6j1$1@dont-email.me>
In reply to#97025
Le 19/11/2016 à 19:49, DFS a écrit :
> I can't find any active assembly groups to post this to, so I figured
> I'd take a shot here.
>
>
>
> My short python program below summarizes a SQLite database.
>
> How long do you think this would take to do in assembler?

There is no point in rewriting it in assembler!

It will run at the SAME SPEED that python since SQLite is THE slowest 
database around. This is just ridiculous. Buy a good database and your 
program will run much faster!!!

The python overhead is just nothing compared to SQLite performance 
characteristics...


[toc] | [prev] | [next] | [standalone]


#97061

FromDFS <nospam@dfs.com>
Date2016-11-19 23:01 -0500
Message-ID<o0r75f$qd2$2@dont-email.me>
In reply to#97034
On 11/19/2016 3:13 PM, jacobnavia wrote:
> Le 19/11/2016 à 19:49, DFS a écrit :
>> I can't find any active assembly groups to post this to, so I figured
>> I'd take a shot here.
>>
>>
>>
>> My short python program below summarizes a SQLite database.
>>
>> How long do you think this would take to do in assembler?
>
> There is no point in rewriting it in assembler!

The question I was asking was "How long would it take to write similar 
code in assembler?", not how fast the assembler code would run.


> It will run at the SAME SPEED that python since SQLite is THE slowest
> database around. This is just ridiculous.

What's ridiculous?


> Buy a good database and your program will run much faster!!!

SQLite is a good database.

And 1.2 seconds to do that summary is fine for me.  I seriously doubt it 
would be any faster with PostgreSQL or MySQL or Oracle.



> The python overhead is just nothing compared to SQLite performance
> characteristics...

Got any benchmarks to support your claim?

[toc] | [prev] | [next] | [standalone]


#97062

Fromjacobnavia <jacob@jacob.remcomp.fr>
Date2016-11-20 11:43 +0100
Message-ID<o0run3$q8b$1@dont-email.me>
In reply to#97061
Le 20/11/2016 à 05:01, DFS a écrit :
>> There is no point in rewriting it in assembler!
>
> The question I was asking was "How long would it take to write similar
> code in assembler?", not how fast the assembler code would run.

Well rewriting that in C is a 2 hours job. Then you make
gcc -S and ypu have your assembler file

[toc] | [prev] | [next] | [standalone]


#97063

Fromjacobnavia <jacob@jacob.remcomp.fr>
Date2016-11-20 11:44 +0100
Message-ID<o0ruop$q8b$2@dont-email.me>
In reply to#97061
Le 20/11/2016 à 05:01, DFS a écrit :
>> It will run at the SAME SPEED that python since SQLite is THE slowest
>> database around. This is just ridiculous.
>
> What's ridiculous?

The concern about the python overhead is ridiculous. The basic show 
stopper here is not python but SQLite

[toc] | [prev] | [next] | [standalone]


#97076

FromDFS <nospam@dfs.com>
Date2016-11-20 08:36 -0500
Message-ID<o0s8rq$r7n$1@dont-email.me>
In reply to#97063
On 11/20/2016 5:44 AM, jacobnavia wrote:
> Le 20/11/2016 à 05:01, DFS a écrit :
>>> It will run at the SAME SPEED that python since SQLite is THE slowest
>>> database around. This is just ridiculous.
>>
>> What's ridiculous?
>
> The concern about the python overhead is ridiculous. The basic show
> stopper here is not python but SQLite


I didn't have any concern about python overhead.  That was all in your head.

[toc] | [prev] | [next] | [standalone]


#97084

From"James R. Kuyper" <jameskuyper@verizon.net>
Date2016-11-20 10:29 -0500
Message-ID<5985188d-07c5-8ce0-4535-50f1e72adaf1@verizon.net>
In reply to#97076
On 11/20/2016 08:36 AM, DFS wrote:
> On 11/20/2016 5:44 AM, jacobnavia wrote:
>> Le 20/11/2016 à 05:01, DFS a écrit :
>>>> It will run at the SAME SPEED that python since SQLite is THE slowest
>>>> database around. This is just ridiculous.
>>>
>>> What's ridiculous?
>>
>> The concern about the python overhead is ridiculous. The basic show
>> stopper here is not python but SQLite
>
>
> I didn't have any concern about python overhead.  That was all in your head.

By far the most common reason for wanting to replace code in a higher 
level language with assembler is to get better speed. Jacob is assuming 
that's your reason, though you never explicitly said so. I have to agree 
with him - it's a reasonable assumption - there's not many other good 
reasons for doing that. However, it would have been better for him to 
ask why you want to convert to assembler, rather than assuming that your 
reason was the obvious one.

[toc] | [prev] | [next] | [standalone]


#97085

Fromjacobnavia <jacob@jacob.remcomp.fr>
Date2016-11-20 16:40 +0100
Message-ID<o0sg4c$kms$1@dont-email.me>
In reply to#97084
Le 20/11/2016 à 16:29, James R. Kuyper a écrit :
> By far the most common reason for wanting to replace code in a higher
> level language with assembler is to get better speed.

I just can't see any other reason to pass from python to asm.
If you want to eliminate any dependency on python for instance, you 
would just rewrite it in C or C++, without bothering to go to asm.

> Jacob is assuming
> that's your reason, though you never explicitly said so. I have to agree
> with him - it's a reasonable assumption - there's not many other good
> reasons for doing that.

I just do not see what OTHER reason would make developping in asm a 
better choice than just C.

However, it would have been better for him to
> ask why you want to convert to assembler, rather than assuming that your
> reason was the obvious one.

OK, let's do that.

Mr "DFS" *WHY* you want to write asm pleeeeeze?

[toc] | [prev] | [next] | [standalone]


#97064

Fromjacobnavia <jacob@jacob.remcomp.fr>
Date2016-11-20 11:45 +0100
Message-ID<o0ruqv$q8b$3@dont-email.me>
In reply to#97061
Le 20/11/2016 à 05:01, DFS a écrit :
> SQLite is a good database.
>
Yes it is a bargain at that price.

> And 1.2 seconds to do that summary is fine for me.  I seriously doubt it
> would be any faster with PostgreSQL or MySQL or Oracle.

Sure. Then, why is python such a problem?

[toc] | [prev] | [next] | [standalone]


#97065

Fromjacobnavia <jacob@jacob.remcomp.fr>
Date2016-11-20 11:46 +0100
Message-ID<o0rusf$q8b$4@dont-email.me>
In reply to#97061
Le 20/11/2016 à 05:01, DFS a écrit :
>> The python overhead is just nothing compared to SQLite performance
>> characteristics...
>
> Got any benchmarks to support your claim?

Just use Google

For instance
http://zenadmin.org/en/blog/post720.html

[toc] | [prev] | [next] | [standalone]


#97069

FromBartC <bc@freeuk.com>
Date2016-11-20 11:49 +0000
Message-ID<o0s2iv$6sb$1@dont-email.me>
In reply to#97061
On 20/11/2016 04:01, DFS wrote:
> On 11/19/2016 3:13 PM, jacobnavia wrote:
>> Le 19/11/2016 à 19:49, DFS a écrit :
>>> I can't find any active assembly groups to post this to, so I figured
>>> I'd take a shot here.
>>>
>>>
>>>
>>> My short python program below summarizes a SQLite database.
>>>
>>> How long do you think this would take to do in assembler?
>>
>> There is no point in rewriting it in assembler!
>
> The question I was asking was "How long would it take to write similar
> code in assembler?", not how fast the assembler code would run.

OK. That depends on how much code you want to convert.

For example, how long would it take to write this C in assembly code:

  double x;
  ....
  printf("%g\n",x);

If you wanted to rewrite the printf function in ASM, complete with 
variadic parameters, and as part of a general *printf family, that's a 
lot of work. (And duplicating the exact behaviour of Python code might 
be a magnitude or two more.)

If it is only necessary to display a floating value to the console, 
followed by a newline, then it is considerably simpler. But it is still 
not trivial to write a general floating point to text conversion routine.

Or you might just want to use C's printf from ASM, which is the simplest 
of all and might be half a dozen instructions that include:

       call printf

But it's also the option that makes the least sense, as 99.99% of the 
work is done in printf and OS routines, so there is no performance 
advantage in writing ASM.

-- 
Bartc

[toc] | [prev] | [next] | [standalone]


#97035

FromNoob <root@127.0.0.1>
Date2016-11-19 21:23 +0100
Message-ID<o0qcb5$a0i$1@dont-email.me>
In reply to#97025
On 19/11/2016 19:49, DFS wrote:

> I can't find any active assembly groups to post this to, so I figured 
> I'd take a shot here.

I couldn't find any active blueberry muffin groups, and I came
to the same conclusion as you did.

> My short python program below summarizes a SQLite database.
> How long do you think this would take to do in assembler?

https://en.wikipedia.org/wiki/Program_optimization#When_to_optimize

[toc] | [prev] | [next] | [standalone]


#97039

From"James R. Kuyper" <jameskuyper@verizon.net>
Date2016-11-19 15:58 -0500
Message-ID<ec039720-3233-7d07-d0bf-02e096279757@verizon.net>
In reply to#97035
On 11/19/2016 03:23 PM, Noob wrote:
> On 19/11/2016 19:49, DFS wrote:
>
>> I can't find any active assembly groups to post this to, so I figured
>> I'd take a shot here.
>
> I couldn't find any active blueberry muffin groups, and I came
> to the same conclusion as you did.

That depends upon what kind of blueberry muffins you're talking about. 
:-) The first six pages of results from a Google Groups search for 
"blueberry muffin" were about the Mimi Holliday Blueberry Muffin Silk & 
Lace Thong. The next several pages were about blueberry muffin-scented 
candles and soap. Muffin recipes are pretty far down on the list.

I didn't find any forums specializing in blueberry muffins. However, 
there's lots of cooking forums (if that's what you're looking for). 
Thongs and candles also have appropriate forums.

[toc] | [prev] | [next] | [standalone]


#97052

FromRobert Spanjaard <spamtrap@arumes.com>
Date2016-11-20 00:26 +0100
Message-ID<o0qn2v$1s8f$1@gioia.aioe.org>
In reply to#97039
On 19-11-16 21:58, James R. Kuyper wrote:
>> I couldn't find any active blueberry muffin groups, and I came
>> to the same conclusion as you did.
>
> That depends upon what kind of blueberry muffins you're talking about.
> :-) The first six pages of results from a Google Groups search for
> "blueberry muffin" were about the Mimi Holliday Blueberry Muffin Silk &
> Lace Thong.

You do realise searches might be catered to your search and browsing
history, right? No thongs here...

http://www.arumes.com/temp/bbmuff.png

-- 
Robert Spanjaard

[toc] | [prev] | [next] | [standalone]


#97054 — [OT] blueberry muffins

From"James R. Kuyper" <jameskuyper@verizon.net>
Date2016-11-19 18:40 -0500
Subject[OT] blueberry muffins
Message-ID<ae3b5ebc-6e2b-f184-9e95-a04e5d8c1488@verizon.net>
In reply to#97052
On 11/19/2016 06:26 PM, Robert Spanjaard wrote:
> On 19-11-16 21:58, James R. Kuyper wrote:
>>> I couldn't find any active blueberry muffin groups, and I came
>>> to the same conclusion as you did.
>>
>> That depends upon what kind of blueberry muffins you're talking about.
>> :-) The first six pages of results from a Google Groups search for
>> "blueberry muffin" were about the Mimi Holliday Blueberry Muffin Silk &
>> Lace Thong.
>
> You do realise searches might be catered to your search and browsing
> history, right? No thongs here...
>
> http://www.arumes.com/temp/bbmuff.png

That's a Google search, and I get the same results as you did from such 
a search. The search I was referring to above was a Google Groups search:
<https://groups.google.com/forum/#!search/blueberry$20muffin>. What 
results do you get from that search?

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.c


csiph-web