我最近一直在尝试提高软件的性能,该软件花费 60% 的时间在 hashmap 中搜索(通过 valgrind profiler 确认)。
当前的实现正在使用boost::unordered_map<long long, FrequencyKey>. 我想与它进行比较google::dense_hash_map<long long, FrequencyKey>。我改变了代码中的一行
boost::unordered_map<long long, FrequencyKey> result;
Run Code Online (Sandbox Code Playgroud)
到
google::dense_hash_map<long long, FrequencyKey> result;
result.set_empty_key(-1);
Run Code Online (Sandbox Code Playgroud)
地图的接口在两个地方被调用。大循环之前result.clear()。循环内result[key]。
我boost::unordered_map<long long, FrequencyKey>的软件性能是118 req/s。通过上面列出的更改,我得到了0.5 req/s。
我显然做错了什么,但在查看文档和 github代码后我自己无法弄清楚。
我正在 CentOS 6.5 上使用 gcc/g++ 4.4.7 编译代码。
我的应用是测量捕获音频的音量作为样本绝对幅度的函数.
我注意到android.media.AudioRecord了Android SDK 中的意外行为.让我们假设以下流程:
麦克风周围的噪音是由具有恒定音量设置的电视产生的.针对点2测量的值在[55-65]范围内,针对点4测量的值在[15-25]范围内(请参见下面的2.和4的音频可视化).
我知道发生电话时必须进行一些音量调整.是否有可能监控这些调整或摆脱它们?
我已经尝试过AutomaticGainControl,但我的Nexus 5不支持它,我不想使用它,因为目标设备可能也不支持它.
更新 该音量调整正在发生的事情不是只有在电话.我刚刚注意到当手机正躺在桌子上测量音量时的相同行为.
我想为Android小部件定义不同的可用样式.在下面的示例中,有两个ImageView小部件,其中一个使用我的"主题"样式,另一个使用manualy样式.我希望以我coluld省略'base_theme'前缀的方式实现配置文件,以便可以根据活动主题配置自动确定.
有关编写主题的文档提到了如何更改所有ImageView或按钮的样式,而不是具有样式属性的特定样式.我发现可以通过使用可设置样式的自定义组件来解决我的问题,但我认为有一些更好的方法来解决我的问题.
base_style.xml
<style name="base_theme" parent="android:Theme.NoTitleBar">
</style>
<style name="base_theme.event_list_filter">
<item name="android:orientation">horizontal</item>
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_margin">10dp</item>
<item name="android:background">@drawable/base_white_rounded</item>
</style>
<style name="base_theme.base_event_list_filter_image">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:padding">10dp</item>
<item name="android:background">@drawable/vr_black_border</item>
</style>
<style name="base_theme.base_event_list_scrollable">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">0dp</item>
<item name="android:layout_weight">1</item>
<item name="android:background">@drawable/base_white_rounded</item>
</style>
<style name="base_theme.base_event_list_table">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
</style>
Run Code Online (Sandbox Code Playgroud)
activity_layout.xml
<LinearLayout style="@style/base_theme.base_event_list_filter" >
<ImageView
style="@style/base_theme.base_event_list_filter_image"
android:src="@drawable/pic0" />
<ImageView
...
android:src="@drawable/pic1" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助,
Maciek