kryton9
Newbie

Posts: 40
|
 |
« Reply #30 on: May 15, 2012, 07:59:08 AM » |
|
Glad you got it working under Linux.
|
|
|
|
|
Logged
|
|
|
|
|
support
|
 |
« Reply #31 on: May 17, 2012, 09:48:23 PM » |
|
For those wondering what a Facade is. If you go to the SL4A API one of the things you notice is the word Facade at the end of each API. Facade refers to a software design pattern. A software design pattern is a generic reusable solution to a problem that occurs in a specific context in software design. So, a facade software design pattern, represented by a facade is an object that provides a simplified interface to a larger body of code, like a class library. As a developer you might want to do this to make the library more readable, and reduce dependencies of code on the inner workings of a given library. In our case, the facade object is Android, and it provides a single, simple interface to the Android SDK, which is huge (relatively speaking). The Android facade object provides a simple interface to a number of things including battery manager, camera functionality, media player, settings api, speech recognition api, web cam functionality just to name a few things.
|
|
|
|
|
Logged
|
ScriptBasic Project Manager
|
|
|
kryton9
Newbie

Posts: 40
|
 |
« Reply #32 on: May 20, 2012, 11:12:26 AM » |
|
Updated the attachment to the latest working python and scriptbasic scripts for benchmarking. Thanks to John's help.John, I started to do some benchmarking, but am getting errors I can't figure out why in Scriptbasic being a noob to the language. It is based on code here:http://onlyjob.blogspot.com/2011/03/perl5-python-ruby-php-c-c-lua-tcl.html The benchmark as written takes too much time, so I modified it to stop after 2 results. Here is the python script that I tested on my gaming notebook and on my android tablet. #!/usr/bin/python -u import re import time import sys
str='abcdefgh'+'efghefgh' imax=1024/len(str)*1024*4 # 4mb
starttime=time.time(); print "exec.tm.sec\tstr.length"
gstr='' i=0 twice = 0 while (i < imax+1000): i=i+1 gstr+=str gstr=re.sub('efgh','____',gstr) lngth=len(str)*i if(lngth % (1024*256) == 0): print int(time.time()-starttime),"sec\t\t",(lngth/1024),"kb" twice+=1 if(twice == 2): break # don't want to wait for the whole test
print "\nFinished" Here is as far as I could get in SB port: s ="abcdefgh"+"efghefgh" imax = 1024 / LEN(s) * 1024 * 4
starttime = NOW PRINT "exec.tm.sec\tstr.length"
gstr="" i=0 c = 0 WHILE ( i < imax + 1000 ) i=i+1 gstr+=s gstr=REPLACE(gstr,'efgh','____') lngth=LEN(s)*i IF(lngth % (1024*256) = 0) THEN PRINT INT(NOW -starttime),"sec\t\t",(lngth/1024),"kb" c+=1 IF c= 2 THEN GOTO finito' don't want to wait for the whole test END IF WEND
finito: PRINT "\nFinished" Results of the python tests: Gaming Notebook Python 2.6: exec.tm.sec str.length 3 sec 256 kb 15 sec 512 kb Android Tablet sl4a Python: exec.tm.sec str.length 36 sec 256 kb 157 sec 512 kb
|
|
|
« Last Edit: May 20, 2012, 08:37:14 PM by kryton9 »
|
Logged
|
|
|
|
|
support
|
 |
« Reply #33 on: May 20, 2012, 11:46:29 AM » |
|
Don't forget to use & not + for string concatenation. It seems that imax is some kind of reserve keyword. SB doesn't support single quote for declaring strings. s ="abcdefgh" & "efghefgh" i_max = 1024 / LEN(s) * 1024 * 4
starttime = NOW PRINT "exec.tm.sec\tstr.length\n"
gstr="" i=0 c = 0 WHILE ( i < i_max + 1000 ) i=i+1 gstr&=s gstr=REPLACE(gstr,"efgh","____") lngth=LEN(s)*i IF(lngth % (1024*256) = 0) THEN PRINT INT(NOW -starttime)," sec\t\t",(lngth/1024)," KB\n" c+=1 IF c= 2 THEN GOTO finito END IF WEND
finito: PRINT "\nFinished\n"
jrs@laptop:~/sb/test$ scriba kentbench.sb exec.tm.sec str.length 107 sec 256 KB 436 sec 512 KB Finished jrs@laptop:~/sb/test$ Please check the code to make sure the SB version is doing the same as the other languages. Python test on my laptop: jrs@laptop:~/sb/bench$ python pstr.py exec.tm.sec str.length 9 sec 256 kb 50 sec 512 kb Finished jrs@laptop:~/sb/bench$ I wonder how this would run under BaCon?
|
|
|
|
« Last Edit: May 20, 2012, 04:46:29 PM by support »
|
Logged
|
ScriptBasic Project Manager
|
|
|
kryton9
Newbie

Posts: 40
|
 |
« Reply #34 on: May 20, 2012, 08:32:54 PM » |
|
Thanks John for finding the problems in the test script and making a nice working script.
Here are my results:
Gaming Notebook scriba bm.sb exec.tm.sec str.length 27 sec 256 KB 107 sec 512 KB
Gaming Notebook Python 2.6: exec.tm.sec str.length 3 sec 256 kb 15 sec 512 kb
Android Tablet scriba bm.sb 281 sec 256 KB 1148 sec 512 KB
Android Tablet sl4a Python: exec.tm.sec str.length 36 sec 256 kb 157 sec 512 kb
|
|
|
|
|
Logged
|
|
|
|
|
support
|
 |
« Reply #35 on: May 20, 2012, 09:47:28 PM » |
|
I solved the problem with REPLACE and happy with the results. Test code grows text string by adding another string in cycle until it grows up to 4 mb. Each iteration substitutes some text. Every time string becomes 256 KiB larger program prints number of seconds passed since beginning of test.
s ="abcdefghefghefgh" i_max = 1024 / LEN(s) * 1024 * 4
starttime = NOW PRINT "exec.tm.sec\tstr.length\n"
gstr="" i=0 c = 0 WHILE ( i < i_max + 1000 ) i=i+1 gstr&=s lngth=LEN(s)*i gstr=REPLACE(gstr,"efgh","____",undef,lngth-16) IF(lngth % (1024*256) = 0) THEN PRINT INT(NOW -starttime)," sec\t\t",(lngth/1024)," KB\n" c+=1 IF c= 2 THEN GOTO finito END IF WEND
finito: PRINT "\nFinished\n"
jrs@laptop:~/sb/test$ scriba kentbench.sb exec.tm.sec str.length 5 sec 256 KB 34 sec 512 KB Finished jrs@laptop:~/sb/test$ abcd____________
abcd____________abcd____________
abcd____________abcd____________abcd____________
abcd____________abcd____________abcd____________abcd____________
I compiled the C version for a reference base. (1st MB) jrs@laptop:~/sb/bench$ ./cstr exec.tm.sec str.length 2sec 256kb 6sec 512kb 17sec 768kb 34sec 1024kb ^C jrs@laptop:~/sb/bench$
|
|
|
|
« Last Edit: May 21, 2012, 12:07:15 AM by support »
|
Logged
|
ScriptBasic Project Manager
|
|
|
kryton9
Newbie

Posts: 40
|
 |
« Reply #36 on: May 21, 2012, 12:54:53 PM » |
|
Nice updates John. The author of the benchmarks wrote that he wasn't going for optimization's and trying to keep the code uniform across all languages. But it is interesting to see how you did your improvements. I did the java test on the notebook. It runs through eclipse, but not stand alone. notebook: exec.tm.sec str.length 8sec 256kb 34sec 512kb
To run you need to unzip the attachment into your eclipse workspace folder and open it from the project menu in eclipse and then run.
|
bm.7z (2.05 KB - downloaded 29 times.)
|
|
|
Logged
|
|
|
|
|
support
|
 |
« Reply #37 on: May 21, 2012, 05:23:13 PM » |
|
Kent,
I don't have Eclipse installed and don't want to trash my development system with installing Java and all the other dependencies that go with it. I'll take your word on the results and factor the numbers based on your Python run on your gaming netbook.
John
|
|
|
|
|
Logged
|
ScriptBasic Project Manager
|
|
|
kryton9
Newbie

Posts: 40
|
 |
« Reply #38 on: May 21, 2012, 05:43:16 PM » |
|
I understand John, in fact it is so screwy now with Java. You have Java and OpenJava, there is version 6 the stable release and 7 which has quirks. I never cared for Eclipse, too me it is buggy compared to other IDE's I use. I just installed it to tinker with Android and what you are doing with SB and Android. I personally am not happy with Android, it is not what I expected. For a phone it is fine, but for a true cross platform OS, it doesn't have the right foundation in my book.
I just look at my tablet as a media source at bedtime anymore. It is not the development toy I thought it was going to be.
|
|
|
|
|
Logged
|
|
|
|
|
support
|
 |
« Reply #39 on: May 21, 2012, 06:07:21 PM » |
|
I just look at my tablet as a media source at bedtime anymore. It is not the development toy I thought it was going to be. Don't give up so soon. You haven't even played with the GUI yet. (fullscreen, controls, events, ...) The SQLite3 Facade is coming from what I have been told. I plan to use SB Android on a pad with an open source medical practice package as the input device. Check out the Android Framework PDF I attached.
|
|
|
« Last Edit: May 21, 2012, 08:45:04 PM by support »
|
Logged
|
ScriptBasic Project Manager
|
|
|
|
support
|
 |
« Reply #40 on: May 22, 2012, 11:16:05 AM » |
|
I was checking into Android emulators that support tablet size screens and physical controls. I was happy to learn that I could create an AVD and specify device characteristics. I found this in the Android Developer Guide that might help with GUI layout and design strategies.
|
|
|
|
|
Logged
|
ScriptBasic Project Manager
|
|
|
kryton9
Newbie

Posts: 40
|
 |
« Reply #41 on: May 22, 2012, 12:23:47 PM » |
|
Thanks for the links John. My interest as you might know currently is in game development and possible future work with robotics, the pc is still the platform for me. I do like my tablet for reading, surfing and watching videos while trying to get to sleep 
|
|
|
|
|
Logged
|
|
|
|
|
support
|
 |
« Reply #42 on: May 22, 2012, 12:33:54 PM » |
|
I want to thank you for being one of the first to join in on the bleeding edge of Android (remote) scripting. I think ScriptBasic has an advantage due to it's small footprint and ease of use. Allowing weekend programmers to script their devices to their needs from anywhere is bound to attract attention. It's still early and the DVM extension module in it's infancy. It would be great to see the ScriptBasic project grow with users and developers.
BTW
The SB dev team has two directions going with the ARM version of ScriptBasic. Steve is working on a native ARM compile of SB while Armando is using the Android NDK. Steve has isolated the looping FUNCTION/SUB issue to an assembler bug in the toolchain.
|
|
|
|
|
Logged
|
ScriptBasic Project Manager
|
|
|
|
support
|
 |
« Reply #43 on: May 23, 2012, 11:16:10 AM » |
|
My interest as you might know currently is in game development and possible future work with robotics, the pc is still the platform for me.   iGuess you only have one Apple left in the basket. 
|
|
|
|
|
Logged
|
ScriptBasic Project Manager
|
|
|
|
|
|