which is faster, GCC or freebasic?
-
- Posts: 42
- Joined: Aug 03, 2009 22:42
which is faster, GCC or freebasic?
would my programs run faster if i wrote them in C++ with GCC or with freebasic? or is the difference negligible?
GCC can do optimizations far beyond what FBC does. If both compilers are working with good and well-structured code, the GCC-generated binary will almost always be faster, and in some cases much faster.TJF wrote:If your code is sloppy, the C++ compiler will find a lot to optimize. The binary should run faster in that case.
If you generate good and well structured FB code there is nothing to optimize and no speed difference between FB and C++ binaries
-
- Posts: 42
- Joined: Aug 03, 2009 22:42
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
Yes, fbc optimization is limited.MichaelW wrote:GCC can do optimizations far beyond what FBC does.
No, I made several speed tests with FB-, C- and C++-code. There was no significant speed difference.MichaelW wrote:If both compilers are working with good and well-structured code, the GCC-generated binary will almost always be faster, and in some cases much faster.
If the FB code is good, there's nothing to optimize and the binaries are equal in speed.
I tried this with fbc 0.21.0. Unfortunately most of my code didn't compile with the C emitter (as far as I remember ENUM isn't supported well).counting_pine wrote:It's worth saying that FB has a work-in-progress backend to emit C code that uses GCC to compile it.
AGS made several speed tests and found some difference. But the FB-code he used can be optimized a lot (from my point of view).
-
- Site Admin
- Posts: 6323
- Joined: Jul 05, 2005 17:32
- Location: Manchester, Lancs
Really? I think FB just treats those like any other constant integer value. I wouldn't expect that to be problematic.TJF wrote:Unfortunately most of my code didn't compile with the C emitter (as far as I remember ENUM isn't supported well).
Generally, GCC should be able to produce better code than FB, although not necessarily by much, but it has a lot more code dedicated to optimisations, and can make better use of things like registers.
I tried again with h_2_bi.bas (version 0.2.0.1) and fbc (Version 0.21.0 (07-17-2010) for linux). Here's the outputcounting_pine wrote:Really? I think FB just treats those like any other constant integer value. I wouldn't expect that to be problematic.
Code: Select all
fbc -gen gcc -O 2 -exx -w all "h_2_bi.bas" (im Verzeichnis: .../src)
h_2_bi.c: In function ‘GETNUMBER’:
h_2_bi.c:1375: warning: initialization makes integer from pointer without a cast
h_2_bi.c:1375: error: initializer element is not computable at load time
h_2_bi.c: In function ‘CHECKH2BI’:
h_2_bi.c:2331: error: ‘label$255’ undeclared (first use in this function)
h_2_bi.c:2331: error: (Each undeclared identifier is reported only once
h_2_bi.c:2331: error: for each function it appears in.)
h_2_bi.c:2331: error: ‘label$256’ undeclared (first use in this function)
h_2_bi.c:2589:1: warning: "vr$725" redefined
h_2_bi.c:2588:1: warning: this is the location of the previous definition
h_2_bi.c:2602:1: warning: "vr$733" redefined
h_2_bi.c:2601:1: warning: this is the location of the previous definition
h_2_bi.c:2615:1: warning: "vr$741" redefined
h_2_bi.c:2614:1: warning: this is the location of the previous definition
h_2_bi.c:2648:1: warning: "vr$753" redefined
h_2_bi.c:2647:1: warning: this is the location of the previous definition
h_2_bi.c:2659:1: warning: "vr$762" redefined
h_2_bi.c:2658:1: warning: this is the location of the previous definition
h_2_bi.c:2668:1: warning: "vr$770" redefined
h_2_bi.c:2667:1: warning: this is the location of the previous definition
h_2_bi.c:2677:1: warning: "vr$778" redefined
h_2_bi.c:2676:1: warning: this is the location of the previous definition
h_2_bi.c:2686:1: warning: "vr$786" redefined
h_2_bi.c:2685:1: warning: this is the location of the previous definition
h_2_bi.c:2695:1: warning: "vr$794" redefined
h_2_bi.c:2694:1: warning: this is the location of the previous definition
h_2_bi.c:2702:1: warning: "vr$800" redefined
h_2_bi.c:2701:1: warning: this is the location of the previous definition
h_2_bi.c:2711:1: warning: "vr$808" redefined
h_2_bi.c:2710:1: warning: this is the location of the previous definition
h_2_bi.c:3065:1: warning: "vr$916" redefined
h_2_bi.c:3064:1: warning: this is the location of the previous definition
h_2_bi.c:3085:1: warning: "vr$929" redefined
h_2_bi.c:3084:1: warning: this is the location of the previous definition
h_2_bi.c:3105:1: warning: "vr$942" redefined
h_2_bi.c:3104:1: warning: this is the location of the previous definition
h_2_bi.c:3125:1: warning: "vr$955" redefined
h_2_bi.c:3124:1: warning: this is the location of the previous definition
h_2_bi.c:3145:1: warning: "vr$968" redefined
h_2_bi.c:3144:1: warning: this is the location of the previous definition
h_2_bi.c:3165:1: warning: "vr$981" redefined
h_2_bi.c:3164:1: warning: this is the location of the previous definition
h_2_bi.c:3185:1: warning: "vr$994" redefined
h_2_bi.c:3184:1: warning: this is the location of the previous definition
h_2_bi.c:3205:1: warning: "vr$1007" redefined
h_2_bi.c:3204:1: warning: this is the location of the previous definition
h_2_bi.c:3225:1: warning: "vr$1020" redefined
h_2_bi.c:3224:1: warning: this is the location of the previous definition
h_2_bi.c:3245:1: warning: "vr$1033" redefined
h_2_bi.c:3244:1: warning: this is the location of the previous definition
h_2_bi.c:3323:1: warning: "vr$1071" redefined
h_2_bi.c:3322:1: warning: this is the location of the previous definition
h_2_bi.c:3343:1: warning: "vr$1084" redefined
h_2_bi.c:3342:1: warning: this is the location of the previous definition
h_2_bi.c:3363:1: warning: "vr$1097" redefined
h_2_bi.c:3362:1: warning: this is the location of the previous definition
h_2_bi.c:3383:1: warning: "vr$1110" redefined
h_2_bi.c:3382:1: warning: this is the location of the previous definition
h_2_bi.c:3403:1: warning: "vr$1123" redefined
h_2_bi.c:3402:1: warning: this is the location of the previous definition
h_2_bi.c:3423:1: warning: "vr$1136" redefined
h_2_bi.c:3422:1: warning: this is the location of the previous definition
h_2_bi.c:3443:1: warning: "vr$1149" redefined
h_2_bi.c:3442:1: warning: this is the location of the previous definition
h_2_bi.c:3463:1: warning: "vr$1162" redefined
h_2_bi.c:3462:1: warning: this is the location of the previous definition
h_2_bi.c:3483:1: warning: "vr$1175" redefined
h_2_bi.c:3482:1: warning: this is the location of the previous definition
h_2_bi.c:3503:1: warning: "vr$1188" redefined
h_2_bi.c:3502:1: warning: this is the location of the previous definition
h_2_bi.c:3523:1: warning: "vr$1201" redefined
h_2_bi.c:3522:1: warning: this is the location of the previous definition
h_2_bi.c:3543:1: warning: "vr$1214" redefined
h_2_bi.c:3542:1: warning: this is the location of the previous definition
h_2_bi.c:3563:1: warning: "vr$1227" redefined
h_2_bi.c:3562:1: warning: this is the location of the previous definition
h_2_bi.c:3583:1: warning: "vr$1240" redefined
h_2_bi.c:3582:1: warning: this is the location of the previous definition
h_2_bi.c:3603:1: warning: "vr$1253" redefined
h_2_bi.c:3602:1: warning: this is the location of the previous definition
h_2_bi.c:3623:1: warning: "vr$1266" redefined
h_2_bi.c:3622:1: warning: this is the location of the previous definition
h_2_bi.c:3643:1: warning: "vr$1279" redefined
h_2_bi.c:3642:1: warning: this is the location of the previous definition
h_2_bi.c:3663:1: warning: "vr$1292" redefined
h_2_bi.c:3662:1: warning: this is the location of the previous definition
h_2_bi.c:3683:1: warning: "vr$1305" redefined
h_2_bi.c:3682:1: warning: this is the location of the previous definition
h_2_bi.c:3703:1: warning: "vr$1318" redefined
h_2_bi.c:3702:1: warning: this is the location of the previous definition
h_2_bi.c:3723:1: warning: "vr$1331" redefined
h_2_bi.c:3722:1: warning: this is the location of the previous definition
h_2_bi.c:3785:1: warning: "vr$1365" redefined
h_2_bi.c:3784:1: warning: this is the location of the previous definition
h_2_bi.c:3805:1: warning: "vr$1378" redefined
h_2_bi.c:3804:1: warning: this is the location of the previous definition
h_2_bi.c:3825:1: warning: "vr$1391" redefined
h_2_bi.c:3824:1: warning: this is the location of the previous definition
h_2_bi.c:3845:1: warning: "vr$1404" redefined
h_2_bi.c:3844:1: warning: this is the location of the previous definition
h_2_bi.c:3862:1: warning: "vr$1414" redefined
h_2_bi.c:3861:1: warning: this is the location of the previous definition
h_2_bi.c:3882:1: warning: "vr$1427" redefined
h_2_bi.c:3881:1: warning: this is the location of the previous definition
h_2_bi.c:3902:1: warning: "vr$1440" redefined
h_2_bi.c:3901:1: warning: this is the location of the previous definition
h_2_bi.c:3922:1: warning: "vr$1453" redefined
h_2_bi.c:3921:1: warning: this is the location of the previous definition
h_2_bi.c:3942:1: warning: "vr$1466" redefined
h_2_bi.c:3941:1: warning: this is the location of the previous definition
h_2_bi.c:3962:1: warning: "vr$1479" redefined
h_2_bi.c:3961:1: warning: this is the location of the previous definition
h_2_bi.c:3982:1: warning: "vr$1492" redefined
h_2_bi.c:3981:1: warning: this is the location of the previous definition
h_2_bi.c:4002:1: warning: "vr$1505" redefined
h_2_bi.c:4001:1: warning: this is the location of the previous definition
h_2_bi.c:4022:1: warning: "vr$1518" redefined
h_2_bi.c:4021:1: warning: this is the location of the previous definition
h_2_bi.c:4081:1: warning: "vr$1549" redefined
h_2_bi.c:4080:1: warning: this is the location of the previous definition
h_2_bi.c:4101:1: warning: "vr$1562" redefined
h_2_bi.c:4100:1: warning: this is the location of the previous definition
h_2_bi.c:4121:1: warning: "vr$1575" redefined
h_2_bi.c:4120:1: warning: this is the location of the previous definition
h_2_bi.c:4141:1: warning: "vr$1588" redefined
h_2_bi.c:4140:1: warning: this is the location of the previous definition
h_2_bi.c:4161:1: warning: "vr$1601" redefined
h_2_bi.c:4160:1: warning: this is the location of the previous definition
h_2_bi.c:4181:1: warning: "vr$1614" redefined
h_2_bi.c:4180:1: warning: this is the location of the previous definition
h_2_bi.c:4201:1: warning: "vr$1627" redefined
h_2_bi.c:4200:1: warning: this is the location of the previous definition
h_2_bi.c:4221:1: warning: "vr$1640" redefined
h_2_bi.c:4220:1: warning: this is the location of the previous definition
h_2_bi.c:4241:1: warning: "vr$1653" redefined
h_2_bi.c:4240:1: warning: this is the location of the previous definition
h_2_bi.c:4261:1: warning: "vr$1666" redefined
h_2_bi.c:4260:1: warning: this is the location of the previous definition
h_2_bi.c:4281:1: warning: "vr$1679" redefined
h_2_bi.c:4280:1: warning: this is the location of the previous definition
h_2_bi.c:4301:1: warning: "vr$1692" redefined
h_2_bi.c:4300:1: warning: this is the location of the previous definition
h_2_bi.c:4321:1: warning: "vr$1705" redefined
h_2_bi.c:4320:1: warning: this is the location of the previous definition
h_2_bi.c:4341:1: warning: "vr$1718" redefined
h_2_bi.c:4340:1: warning: this is the location of the previous definition
h_2_bi.c:4361:1: warning: "vr$1731" redefined
h_2_bi.c:4360:1: warning: this is the location of the previous definition
h_2_bi.c:4381:1: warning: "vr$1744" redefined
h_2_bi.c:4380:1: warning: this is the location of the previous definition
h_2_bi.c:4401:1: warning: "vr$1757" redefined
h_2_bi.c:4400:1: warning: this is the location of the previous definition
h_2_bi.c:4421:1: warning: "vr$1770" redefined
h_2_bi.c:4420:1: warning: this is the location of the previous definition
h_2_bi.c:4441:1: warning: "vr$1783" redefined
h_2_bi.c:4440:1: warning: this is the location of the previous definition
h_2_bi.c:4461:1: warning: "vr$1796" redefined
h_2_bi.c:4460:1: warning: this is the location of the previous definition
h_2_bi.c:4481:1: warning: "vr$1809" redefined
h_2_bi.c:4480:1: warning: this is the location of the previous definition
h_2_bi.c:4501:1: warning: "vr$1822" redefined
h_2_bi.c:4500:1: warning: this is the location of the previous definition
h_2_bi.c:4521:1: warning: "vr$1835" redefined
h_2_bi.c:4520:1: warning: this is the location of the previous definition
h_2_bi.c:4577:1: warning: "vr$1865" redefined
h_2_bi.c:4576:1: warning: this is the location of the previous definition
h_2_bi.c:4597:1: warning: "vr$1878" redefined
h_2_bi.c:4596:1: warning: this is the location of the previous definition
h_2_bi.c:4617:1: warning: "vr$1891" redefined
h_2_bi.c:4616:1: warning: this is the location of the previous definition
h_2_bi.c:4637:1: warning: "vr$1904" redefined
h_2_bi.c:4636:1: warning: this is the location of the previous definition
h_2_bi.c:4657:1: warning: "vr$1917" redefined
h_2_bi.c:4656:1: warning: this is the location of the previous definition
h_2_bi.c:4677:1: warning: "vr$1930" redefined
h_2_bi.c:4676:1: warning: this is the location of the previous definition
h_2_bi.c:4697:1: warning: "vr$1943" redefined
h_2_bi.c:4696:1: warning: this is the location of the previous definition
h_2_bi.c:4717:1: warning: "vr$1956" redefined
h_2_bi.c:4716:1: warning: this is the location of the previous definition
h_2_bi.c:4737:1: warning: "vr$1969" redefined
h_2_bi.c:4736:1: warning: this is the location of the previous definition
h_2_bi.c:4757:1: warning: "vr$1982" redefined
h_2_bi.c:4756:1: warning: this is the location of the previous definition
h_2_bi.c:4777:1: warning: "vr$1995" redefined
h_2_bi.c:4776:1: warning: this is the location of the previous definition
h_2_bi.c:4797:1: warning: "vr$2008" redefined
h_2_bi.c:4796:1: warning: this is the location of the previous definition
h_2_bi.c:4817:1: warning: "vr$2021" redefined
h_2_bi.c:4816:1: warning: this is the location of the previous definition
h_2_bi.c:4837:1: warning: "vr$2034" redefined
h_2_bi.c:4836:1: warning: this is the location of the previous definition
h_2_bi.c:4857:1: warning: "vr$2047" redefined
h_2_bi.c:4856:1: warning: this is the location of the previous definition
h_2_bi.c:4877:1: warning: "vr$2060" redefined
h_2_bi.c:4876:1: warning: this is the location of the previous definition
h_2_bi.c:4897:1: warning: "vr$2073" redefined
h_2_bi.c:4896:1: warning: this is the location of the previous definition
h_2_bi.c:4917:1: warning: "vr$2086" redefined
h_2_bi.c:4916:1: warning: this is the location of the previous definition
h_2_bi.c:4937:1: warning: "vr$2099" redefined
h_2_bi.c:4936:1: warning: this is the location of the previous definition
h_2_bi.c:4957:1: warning: "vr$2112" redefined
h_2_bi.c:4956:1: warning: this is the location of the previous definition
h_2_bi.c:4977:1: warning: "vr$2125" redefined
h_2_bi.c:4976:1: warning: this is the location of the previous definition
h_2_bi.c:4997:1: warning: "vr$2138" redefined
h_2_bi.c:4996:1: warning: this is the location of the previous definition
h_2_bi.c:5017:1: warning: "vr$2151" redefined
h_2_bi.c:5016:1: warning: this is the location of the previous definition
h_2_bi.c:5037:1: warning: "vr$2164" redefined
h_2_bi.c:5036:1: warning: this is the location of the previous definition
h_2_bi.c:5057:1: warning: "vr$2177" redefined
h_2_bi.c:5056:1: warning: this is the location of the previous definition
h_2_bi.c: In function ‘_ZN11CFILEREADERC1ER8FBSTRING’:
h_2_bi.c:5274: warning: pointer targets in passing argument 5 of ‘fb_FileGetIOB’ differ in signedness
h_2_bi.c:361: note: expected ‘uinteger *’ but argument is of type ‘integer *’
h_2_bi.c:5278: error: ‘label$551’ undeclared (first use in this function)
h_2_bi.c:5278: error: ‘label$552’ undeclared (first use in this function)
h_2_bi.c:5348: error: ‘label$561’ undeclared (first use in this function)
h_2_bi.c:5348: error: ‘label$562’ undeclared (first use in this function)
h_2_bi.c:5417: error: ‘label$567’ undeclared (first use in this function)
h_2_bi.c:5417: error: ‘label$568’ undeclared (first use in this function)
h_2_bi.c: In function ‘_ZN6MACROSC1ER8FBSTRINGP7OPTIONSP12ERRORHANDLER’:
h_2_bi.c:14769: error: ‘label$1903’ undeclared (first use in this function)
h_2_bi.c:14769: error: ‘label$1904’ undeclared (first use in this function)
h_2_bi.c: In function ‘_ZN6MACROS10GETPARLISTER8FBSTRINGRiiRAS0_’:
h_2_bi.c:15197: error: ‘label$1960’ undeclared (first use in this function)
h_2_bi.c:15197: error: ‘label$1961’ undeclared (first use in this function)
h_2_bi.c: In function ‘_ZN6MACROS5CHECKER8FBSTRINGS1_RiiS1_’:
h_2_bi.c:15412: error: ‘label$1980’ undeclared (first use in this function)
h_2_bi.c:15412: error: ‘label$1981’ undeclared (first use in this function)
h_2_bi.c:15428:1: warning: "vr$5783" redefined
h_2_bi.c:15427:1: warning: this is the location of the previous definition
h_2_bi.c: In function ‘_ZN8BIWRITERC1ER8FBSTRINGP6CONFIGP7OPTIONSP6MACROSP11CFILEREADERP12ERRORHANDLER’:
h_2_bi.c:15968: error: ‘label$2035’ undeclared (first use in this function)
h_2_bi.c:15968: error: ‘label$2036’ undeclared (first use in this function)
h_2_bi.c: In function ‘_ZN8BIWRITERD1Ev’:
h_2_bi.c:16210: error: ‘label$2055’ undeclared (first use in this function)
h_2_bi.c:16210: error: ‘label$2056’ undeclared (first use in this function)
h_2_bi.c:16370: error: ‘label$2063’ undeclared (first use in this function)
h_2_bi.c:16370: error: ‘label$2064’ undeclared (first use in this function)
h_2_bi.c:16732: error: ‘label$2075’ undeclared (first use in this function)
h_2_bi.c:16732: error: ‘label$2076’ undeclared (first use in this function)
h_2_bi.c:17532:1: warning: "vr$6810" redefined
h_2_bi.c:17531:1: warning: this is the location of the previous definition
h_2_bi.c:17827:1: warning: "vr$6948" redefined
h_2_bi.c:17826:1: warning: this is the location of the previous definition
h_2_bi.c:18326:1: warning: "vr$7185" redefined
h_2_bi.c:18325:1: warning: this is the location of the previous definition
h_2_bi.c:18345:1: warning: "vr$7203" redefined
h_2_bi.c:18344:1: warning: this is the location of the previous definition
h_2_bi.c:18362:1: warning: "vr$7213" redefined
h_2_bi.c:18361:1: warning: this is the location of the previous definition
h_2_bi.c:18373:1: warning: "vr$7223" redefined
h_2_bi.c:18372:1: warning: this is the location of the previous definition
h_2_bi.c:19414:1: warning: "vr$7646" redefined
h_2_bi.c:19413:1: warning: this is the location of the previous definition
h_2_bi.c:19433:1: warning: "vr$7658" redefined
h_2_bi.c:19432:1: warning: this is the location of the previous definition
h_2_bi.c:19453:1: warning: "vr$7671" redefined
h_2_bi.c:19452:1: warning: this is the location of the previous definition
h_2_bi.c:19720:1: warning: "vr$7826" redefined
h_2_bi.c:19719:1: warning: this is the location of the previous definition
h_2_bi.c:19735:1: warning: "vr$7839" redefined
h_2_bi.c:19734:1: warning: this is the location of the previous definition
h_2_bi.c:19757:1: warning: "vr$7855" redefined
h_2_bi.c:19756:1: warning: this is the location of the previous definition
h_2_bi.c:19782:1: warning: "vr$7874" redefined
h_2_bi.c:19781:1: warning: this is the location of the previous definition
h_2_bi.c:20344:1: warning: "vr$8196" redefined
h_2_bi.c:20343:1: warning: this is the location of the previous definition
h_2_bi.c:20487:1: warning: "vr$8253" redefined
h_2_bi.c:20486:1: warning: this is the location of the previous definition
h_2_bi.c:20588:1: warning: "vr$8309" redefined
h_2_bi.c:20587:1: warning: this is the location of the previous definition
h_2_bi.c:20648:1: warning: "vr$8345" redefined
h_2_bi.c:20647:1: warning: this is the location of the previous definition
h_2_bi.c:20696:1: warning: "vr$8375" redefined
h_2_bi.c:20695:1: warning: this is the location of the previous definition
h_2_bi.c:20744:1: warning: "vr$8405" redefined
h_2_bi.c:20743:1: warning: this is the location of the previous definition
h_2_bi.c:20792:1: warning: "vr$8435" redefined
h_2_bi.c:20791:1: warning: this is the location of the previous definition
h_2_bi.c:20836:1: warning: "vr$8463" redefined
h_2_bi.c:20835:1: warning: this is the location of the previous definition
h_2_bi.c:21246:1: warning: "vr$8678" redefined
h_2_bi.c:21245:1: warning: this is the location of the previous definition
h_2_bi.c:21626:1: warning: "vr$8866" redefined
h_2_bi.c:21625:1: warning: this is the location of the previous definition
h_2_bi.c:21909:1: warning: "vr$8976" redefined
h_2_bi.c:21908:1: warning: this is the location of the previous definition
h_2_bi.c:22406:1: warning: "vr$9193" redefined
h_2_bi.c:22405:1: warning: this is the location of the previous definition
h_2_bi.c:22914:1: warning: "vr$9343" redefined
h_2_bi.c:22913:1: warning: this is the location of the previous definition
h_2_bi.c:22967:1: warning: "vr$9376" redefined
h_2_bi.c:22966:1: warning: this is the location of the previous definition
h_2_bi.c:23013:1: warning: "vr$9404" redefined
h_2_bi.c:23012:1: warning: this is the location of the previous definition
h_2_bi.c:23030:1: warning: "vr$9418" redefined
h_2_bi.c:23029:1: warning: this is the location of the previous definition
h_2_bi.c:23342:1: warning: "vr$9603" redefined
h_2_bi.c:23341:1: warning: this is the location of the previous definition
h_2_bi.c:23462:1: warning: "vr$9675" redefined
h_2_bi.c:23461:1: warning: this is the location of the previous definition
h_2_bi.c:23712:1: warning: "vr$9796" redefined
h_2_bi.c:23711:1: warning: this is the location of the previous definition
h_2_bi.c:24051:1: warning: "vr$9961" redefined
h_2_bi.c:24050:1: warning: this is the location of the previous definition
h_2_bi.c: In function ‘_ZN6H_2_BI7GENCASTERiRi’:
h_2_bi.c:24202: error: ‘label$2815’ undeclared (first use in this function)
h_2_bi.c:24202: error: ‘label$2816’ undeclared (first use in this function)
h_2_bi.c:26608:1: warning: "vr$10778" redefined
h_2_bi.c:26607:1: warning: this is the location of the previous definition
h_2_bi.c:26729:1: warning: "vr$10826" redefined
h_2_bi.c:26728:1: warning: this is the location of the previous definition
h_2_bi.c:26825:1: warning: "vr$10885" redefined
h_2_bi.c:26824:1: warning: this is the location of the previous definition
h_2_bi.c:26905:1: warning: "vr$10940" redefined
h_2_bi.c:26904:1: warning: this is the location of the previous definition
h_2_bi.c:26985:1: warning: "vr$10995" redefined
h_2_bi.c:26984:1: warning: this is the location of the previous definition
h_2_bi.c:27112:1: warning: "vr$11076" redefined
h_2_bi.c:27111:1: warning: this is the location of the previous definition
h_2_bi.c:27181:1: warning: "vr$11123" redefined
h_2_bi.c:27180:1: warning: this is the location of the previous definition
h_2_bi.c:27242:1: warning: "vr$11162" redefined
h_2_bi.c:27241:1: warning: this is the location of the previous definition
h_2_bi.c:27300:1: warning: "vr$11201" redefined
h_2_bi.c:27299:1: warning: this is the location of the previous definition
h_2_bi.c:27348:1: warning: "vr$11233" redefined
h_2_bi.c:27347:1: warning: this is the location of the previous definition
h_2_bi.c:27410:1: warning: "vr$11265" redefined
h_2_bi.c:27409:1: warning: this is the location of the previous definition
h_2_bi.c:27476:1: warning: "vr$11318" redefined
h_2_bi.c:27475:1: warning: this is the location of the previous definition
h_2_bi.c:29197:1: warning: "vr$12077" redefined
h_2_bi.c:29196:1: warning: this is the location of the previous definition
h_2_bi.c:29629:1: warning: "vr$12357" redefined
h_2_bi.c:29628:1: warning: this is the location of the previous definition
h_2_bi.c:29716:1: warning: "vr$12408" redefined
h_2_bi.c:29715:1: warning: this is the location of the previous definition
h_2_bi.c:29763:1: warning: "vr$12438" redefined
h_2_bi.c:29762:1: warning: this is the location of the previous definition
h_2_bi.c:29810:1: warning: "vr$12468" redefined
h_2_bi.c:29809:1: warning: this is the location of the previous definition
Re: which is faster, GCC or freebasic?
I would prototype my code in FB. If it's slow, then convert it to C++. If it's still slow, then obviously, the code itself is slow or you need a faster computer.deepthought wrote:would my programs run faster if i wrote them in C++ with GCC or with freebasic? or is the difference negligible?
Todays computers are really very fast that you wont notice a difference in speed doing trivial matters like scanline/block moves no matter the compiler of choice.
My take on this is:
"Code what makes you productive and happy"
What sort of code were you testing? I should have specified that I was speaking primarily of compute-bound code. Memory-bound code may not benefit from optimization, and I/O-bound code probably will not.TJF wrote:No, I made several speed tests with FB-, C- and C++-code. There was no significant speed difference.MichaelW wrote:If both compilers are working with good and well-structured code, the GCC-generated binary will almost always be faster, and in some cases much faster.
http://www.freebasic.net/forum/viewtopic.php?t=6752
I searched my backup and found one of the speed tests regarding prime numbers. IMHO it's compute-bound.MichaelW wrote:What sort of code were you testing? I should have specified that I was speaking primarily of compute-bound code. Memory-bound code may not benefit from optimization, and I/O-bound code probably will not.TJF wrote:No, I made several speed tests with FB-, C- and C++-code. There was no significant speed difference.MichaelW wrote:If both compilers are working with good and well-structured code, the GCC-generated binary will almost always be faster, and in some cases much faster.
http://www.freebasic.net/forum/viewtopic.php?t=6752
The C code
Code: Select all
#include <iostream.h>
bool istPrimzahl(int Zahl)
{
if (Zahl == 2)
return true;
for (int i=2; i<(Zahl/2+1); i++)
if (!(Zahl % i))
return false;
return true;
};
int main()
{
int sum[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
for (int i=1;i<=100000;i++)
{
if (istPrimzahl(i))
sum[i%10] += 1;
}
for (int i=0;i<=9;i++)
{
cout<<"Die Endziffer "<<i<<" kommt "<<sum[i]<<" mal vor."<<endl;
}
return 0;
}
Code: Select all
FUNCTION istPrimzahl(Zahl AS INTEGER) AS INTEGER
IF Zahl = 2 THEN RETURN 1
FOR i AS INTEGER = 2 TO Zahl/2+1
IF (Zahl MOD i)=0 THEN RETURN 0
NEXT : RETURN 1
END FUNCTION
DIM AS INTEGER su(9)
FOR i AS INTEGER = 1 to 100000
IF istPrimzahl(i) THEN su(i MOD 10) += 1
NEXT
FOR i AS INTEGER = 0 to 9
?"Die Endziffer " & i & " kommt: " & su(i) & " mal vor."
NEXT
TJF: That "benchmark" is *very* simple and is not going to offer you a very good idea of their relative speeds. A much better, comprehensive set of benchmarks is here. It's old, from 2008, though. As you can see variants of C/++ are a fair bit faster than FreeBASIC.
Yes, it's one of several simple tests. And it should be simple!TheMG wrote:TJF: That "benchmark" is *very* simple ...
Neither C nor C++ can compile a faster binary in this case and most of the other cases. This is what I need to know. This is what I want to show.
These benchmarks are not better in any case (to answer my questions). The tested source isn't published so I cannot check the quality of the FB source. Since FB has limited optimization, the benchmark results depend a lot on the quality of the FB source. That's why I cannot believe a benchmark without checking the source first.TheMG wrote:A much better, comprehensive set of benchmarks is here. It's old, from 2008, though. As you can see variants of C/++ are a fair bit faster than FreeBASIC.
Once more: binaries compiled from sloppy FB source can be very, very slow -- sloppy C/C++ code can compile to faster binary due to compiler optimization.
But good FB code is nearly as fast as C/C++. The main difference is
and this can only be shown with *very* simple tests. You may see 'inline functions' as an exeption.counting_pine wrote:GCC ... can make better use of things like registers.