Internet Explorer中的JavaScript性能很糟糕.没有新闻.然而,有一些提示和技巧来加快它.例如,有这三 部分 系列.我仍然发现自己无法从中挤出体面的表现.也许你们中的一些人知道还有什么可以做的,所以它更快?
我想要做的是在Javascript中从头开始创建一个中等大小的表.比方说,300行,每行10个单元格.我的电脑需要大约5-6秒才能完成此操作.好的,授予,这是一个5岁的钻机,但仍然太多了.这是我的虚拟代码:
<html>
<body>
<script type="text/javascript">
function MakeTable(parent)
{
var i, j;
var table = document.createElement('table');
var insertRow = table.insertRow;
for ( i = 0; i < 300; i++ )
{
var row = insertRow(-1);
for ( j = 0; j < 10; j++ )
{
var cell = row.insertCell(-1);
cell.innerHTML = i + ' - ' + j;
}
}
parent.appendChild(table);
}
</script>
<div onclick="MakeTable(this);">Click Me!</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
补充:嗯,显然字符串连接(使用array.join)是唯一的方法.好吧,伤心,当然.希望这样做是"正确的"DOM方式.:)
我正在尝试在我的 python 代码上运行 flake8 linter,但我遇到了一些问题。
运行 pip install 给了我这个响应:
~ pip install flake8
Requirement already satisfied: flake8 in ./Library/Python/2.7/lib/python/site-packages
Requirement already satisfied: enum34; python_version < "3.4" in ./Library/Python/2.7/lib/python/site-packages (from flake8)
Requirement already satisfied: configparser; python_version < "3.2" in ./Library/Python/2.7/lib/python/site-packages (from flake8)
Requirement already satisfied: mccabe<0.7.0,>=0.6.0 in ./Library/Python/2.7/lib/python/site-packages (from flake8)
Requirement already satisfied: pycodestyle<2.4.0,>=2.0.0 in ./Library/Python/2.7/lib/python/site-packages (from flake8)
Requirement already satisfied: pyflakes<1.6.0,>=1.5.0 in ./Library/Python/2.7/lib/python/site-packages (from flake8)
Run Code Online (Sandbox Code Playgroud)
但是当我尝试运行它时,我收到了这个错误。
~ flake8 --version
zsh: command not found: flake8
Run Code Online (Sandbox Code Playgroud)
如果这有什么不同,我也在使用 mac。
请任何人都可以帮忙。
我一直在使用resx文件作为静态字符串,以便有一个更改它们的中心位置.问题是在构建和部署项目后我无法更改它们.
部署后我想要更改一些字符串,而不重新启动进程(因此.config文件已经用完).
可以编写有效解析配置文件(XML/JSON/YAML /?)的代码,例如将结果缓存X秒或使用FileSystemWatcher监视它的更改,但是已经完成了这样的事情?
编辑:使用Json.NET和Rashmi Pandit的指针,CacheDependency我写了这个JSON解析类,缓存解析后的结果,直到文件被更改:
public class CachingJsonParser
{
public static CachingJsonParser Create()
{
return new CachingJsonParser(
HttpContext.Current.Server,
HttpContext.Current.Cache);
}
private readonly HttpServerUtility _server;
private readonly Cache _cache;
public CachingJsonParser(HttpServerUtility server, Cache cache)
{
_server = server;
_cache = cache;
}
public T Parse<T>(string relativePath)
{
var cacheKey = "cached_json_file:" + relativePath;
if (_cache[cacheKey] == null)
{
var mappedPath = _server.MapPath(relativePath);
var json = File.ReadAllText(mappedPath);
var result = JavaScriptConvert.DeserializeObject(json, typeof(T));
_cache.Insert(cacheKey, result, new …Run Code Online (Sandbox Code Playgroud) @"F:\LEAFPRODUCT\Bin\Service.exe"
Run Code Online (Sandbox Code Playgroud)
这是物理路径Service.exe,让我知道是否有任何其他替代方式或任何一般方法来查找WrmService.exe窗口应用程序中的物理路径.
在Web应用程序中,我们可以Server.MapPath像这样使用.在这里,我需要减少路径的意思
label1.Text = AssemblyName.GetAssemblyName(@"F:\LEAFPRODUCT\Bin\Service.exe").Version.ToString();
Run Code Online (Sandbox Code Playgroud)
这是我需要在这里减少物理路径的编码,这意味着我不想把这种方式放在我需要的所有文件夹中
label1.Text = AssemblyName.GetAssemblyName("WrmService.exe").Version.ToString();
Run Code Online (Sandbox Code Playgroud)
表示此处仅显示所需的文件名 WrmService.exe
我已经从我的c#应用程序创建了一个xml文件我想在创建后使用该文件,但它向我显示该文件已被使用的异常?我想我必须关闭文件或东西..这里是源代码:
private void button1_Click(object sender, EventArgs e)
{
// Create the XmlDocument.
XmlDocument doc = new XmlDocument();
doc.LoadXml("<item><name>salman</name></item>"); //Your string here
// Save the document to a file and auto-indent the output.
XmlTextWriter writer = new XmlTextWriter(@"D:\data.xml", null);
writer.Formatting = Formatting.Indented;
doc.Save(writer);
///////////////
XmlDataDocument xmlDatadoc = new XmlDataDocument();
xmlDatadoc.DataSet.ReadXml(@"D:\data.xml");// here is the exception!!!!!
//now reading the created file and display it in grid view
DataSet ds = new DataSet("Books DataSet");
ds = xmlDatadoc.DataSet;
dataGridView1.DataSource = ds.DefaultViewManager;
dataGridView1.DataMember = "CP";
Run Code Online (Sandbox Code Playgroud)
}
所以我试图循环一个JSON响应,但我似乎无法做到正确.
片段:
$.getJSON("/playlist/",function(playlists) {
$.each(playlists,function() {
self.playlists[this.playlist.id] = new SC.Playlist(this, self);
console.log(this);
})
})
Run Code Online (Sandbox Code Playgroud)
JSON:
jsonp1311444173992([
{
is_owner: true,
id: "wtf",
playlist: {
id: "latest1",
name: "Hot Tracks1",
version: 0,
tracks: "33+44+55"
}
},
{
is_owner: true,
playlist: {
id: "latest",
name: "Hot Tracks",
smart: true,
version: 0,
smart_filter: {
order: "hotness"
}
}
},
{
is_owner: true,
playlist: {
id: "latest3",
name: "Hot Tracks3",
version: 0,
tracks: "33+44+55"
}
},
{
is_owner: true,
playlist: {
id: "latest4",
name: "Hot …Run Code Online (Sandbox Code Playgroud)