如果我将 Objective-C 用于低级代码,我的 iPhone 应用程序会降低性能吗? [英] Will my iPhone app take a performance hit if I use Objective-C for low level code?

查看:21
本文介绍了如果我将 Objective-C 用于低级代码,我的 iPhone 应用程序会降低性能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 iPhone 或其他便携式硬件上编写 CPU 密集型或 GPU 密集型应用程序时,您必须做出明智的算法决策以加快代码速度.

When programming a CPU intensive or GPU intensive application on the iPhone or other portable hardware, you have to make wise algorithmic decisions to make your code fast.

但是,如果您使用的语言的性能比另一种语言更差,那么即使是出色的算法选择也会很慢.

But even great algorithm choices can be slow if the language you're using performs more poorly than another.

是否有任何硬数据将 Objective-C 与 C++ 进行比较,特别是在 iPhone 上,但可能只是在 Mac 桌面上,用于各种类似语言方面的性能?我很熟悉这篇比较C和Objective-C的文章,但这是比较两种面向对象语言的更大问题.

Is there any hard data comparing Objective-C to C++, specifically on the iPhone but maybe just on the Mac desktop, for performance of various similar language aspects? I am very familiar with this article comparing C and Objective-C, but this is a larger question of comparing two object oriented languages to each other.

例如,C++ vtable 查找真的比 Obj-C 消息快吗?快多少?线程、多态、排序等.在我继续使用重复的对象模型和各种测试代码构建项目之前,我想知道是否有人已经这样做了,结果在哪里.这种类型的测试和比较本身就是一个项目,可能需要相当长的时间.也许这不是一个项目,而是两个并且只有输出可以比较.

For example, is a C++ vtable lookup really faster than an Obj-C message? How much faster? Threading, polymorphism, sorting, etc. Before I go on a quest to build a project with duplicate object models and various test code, I want to know if anybody has already done this and what the results where. This type of testing and comparison is a project in and of itself and can take a considerable amount of time. Maybe this isn't one project, but two and only the outputs can be compared.

我正在寻找硬数据,而不是传福音.像你们中的许多人一样,出于各种原因,我又爱又恨这两种语言.此外,如果有人在积极追求同样的事情,我会很有趣地投入一些代码以查看最终结果,我相信其他人也会提供帮助.我的猜测是它们都有优点和缺点,我的目标是准确找出它们是什么,以便在现实世界中避免/利用它们.

I'm looking for hard data, not evangelism. Like many of you I love and hate both languages for various reasons. Furthermore, if there is someone out there actively pursuing this same thing I'd be interesting in pitching in some code to see the end results, and I'm sure others would help out too. My guess is that they both have strengths and weaknesses, my goal is to find out precisely what they are so that they can be avoided/exploited in real-world scenarios.

推荐答案

Mike Ash 在他的博文 "常见操作的性能比较".另外,这篇文章关于使用 Objective-C++ 调整 iPhone 应用程序的性能,Savoy Software 是一本有趣的读物.

Mike Ash has some hard numbers for performance of various Objective-C method calls versus C and C++ in his post "Performance Comparisons of Common Operations". Also, this post by Savoy Software is an interesting read when it comes to tuning the performance of an iPhone application by using Objective-C++.

与 Objective-C++ 相比,我更喜欢 Objective-C 的简洁、描述性语法,并且没有发现语言本身是我的性能瓶颈的根源.我什至倾向于做一些我知道会牺牲一点性能的事情,如果它们使我的代码更易于维护.

I tend to prefer the clean, descriptive syntax of Objective-C over Objective-C++, and have not found the language itself to be the source of my performance bottlenecks. I even tend to do things that I know sacrifice a little bit of performance if they make my code much more maintainable.

这篇关于如果我将 Objective-C 用于低级代码,我的 iPhone 应用程序会降低性能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆