Search Results

Search found 277 results on 12 pages for 'nam micheal vu'.

Page 4/12 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • why is LZMA SDK (7-zip) so slow

    - by Tono Nam
    I found 7-zip great and I will like to use it on .net applications. I have a 10MB file (a.001) and it takes: 2 seconds to encode. Now it will be nice if I could do the same thing on c#. I have downloaded http://www.7-zip.org/sdk.html LZMA SDK c# source code. I basically copied the CS directory into a console application in visual studio: Then I compiled and eveything compiled smoothly. So on the output directory I placed the file a.001 which is 10MB of size. On the main method that came on the source code I placed: [STAThread] static int Main(string[] args) { // e stands for encode args = "e a.001 output.7z".Split(' '); // added this line for debug try { return Main2(args); } catch (Exception e) { Console.WriteLine("{0} Caught exception #1.", e); // throw e; return 1; } } when I execute the console application the application works great and I get the output a.7z on the working directory. The problem is that it takes so long. It takes about 15 seconds to execute! I have also tried http://stackoverflow.com/a/8775927/637142 approach and it also takes very long. Why is it 10 times slower than the actual program ? Also Even if I set to use only one thread: It still takes much less time (3 seconds vs 15): (Edit) Another Possibility Could it be because C# is slower than assembly or C ? I notice that the algorithm does a lot of heavy operations. For example compare these two blocks of code. They both do the same thing: C void main() { time_t now; int i,j,k,x; long counter ; counter = 0; now = time(NULL); /* LOOP */ for(x=0; x<10; x++) { counter = -1234567890 + x+2; for (j = 0; j < 10000; j++) for(i = 0; i< 1000; i++) for(k =0; k<1000; k++) { if(counter > 10000) counter = counter - 9999; else counter= counter +1; } printf (" %d \n", time(NULL) - now); // display elapsed time } printf("counter = %d\n\n",counter); // display result of counter printf ("Elapsed time = %d seconds ", time(NULL) - now); gets("Wait"); } output c# static void Main(string[] args) { DateTime now; int i, j, k, x; long counter; counter = 0; now = DateTime.Now; /* LOOP */ for (x = 0; x < 10; x++) { counter = -1234567890 + x + 2; for (j = 0; j < 10000; j++) for (i = 0; i < 1000; i++) for (k = 0; k < 1000; k++) { if (counter > 10000) counter = counter - 9999; else counter = counter + 1; } Console.WriteLine((DateTime.Now - now).Seconds.ToString()); } Console.Write("counter = {0} \n", counter.ToString()); Console.Write("Elapsed time = {0} seconds", DateTime.Now - now); Console.Read(); } Output Note how much slower was c#. Both programs where run from outside visual studio on release mode. Maybe that is the reason why it takes so much longer in .net than on c++. Conclusion I cannot seem to know what is causing the problem. I guess I will use 7z.dll and invoke the necessary methods from c#. A library that does that is at: http://sevenzipsharp.codeplex.com/ and that way I am using the same library that 7zip is using as: // dont forget to add reference to SevenZipSharp located on the link I provided static void Main(string[] args) { // load the dll SevenZip.SevenZipCompressor.SetLibraryPath(@"C:\Program Files (x86)\7-Zip\7z.dll"); SevenZip.SevenZipCompressor compress = new SevenZip.SevenZipCompressor(); compress.CompressDirectory("MyFolderToArchive", "output.7z"); }

    Read the article

  • Error: (subscript) logical subscript too long

    - by frespider
    Can some one let me know why I am getting this error and how I can fix it? Here is the code What I am trying to do is remove the rows that associated 1's if the column of that one's less than 10 a0=rep(1,40) a=rep(0:1,20) b=c(rep(1,20),rep(0,20)) c0=c(rep(0,12),rep(1,28)) c1=c(rep(1,5),rep(0,35)) c2=c(rep(1,8),rep(0,32)) c3=c(rep(1,23),rep(0,17)) c4=c(rep(1,6),rep(0,34)) x=matrix(cbind(a0,a,b,c0,c1,c2,c3,c4),nrow=40,ncol=8) nam <- paste("V",2:9,sep="") colnames(x)<-nam dat <- cbind(y=rnorm(40,50,7),x) #=================================== toSum <- colSums(dat) Col <- Val <- NULL for(i in 1:length(toSum)){ if(toSum[i]<10){ Col <- c(Col,colnames(dat)[i]) Val <- c(Val,toSum[i])} } cs <- colSums(dat) < 10 indx <- dat[,which(cs)]==0 for(i in 1:dim(indx)[2]){ datnw <- dat[indx[,i],] dat <- datnw} datnw2 <- dat[, -which(cs)] Thanks

    Read the article

  • [C#] A problem of downloading webpage's HTML source.

    - by Nam Gi VU
    I use System.Net.WebClient.DownloadString(url) to get the HTML source of http://kqxs.vn but what I recieved is a caution text from the web server which says in Vietnamese as: "Xin loi. Chung toi khong the dap ung yeu cau truy cap cua ban... Vui long lien he : [email protected]. Chao ban" which is translated in English as "Sorry. We cannot response to your request... Please contact... Good bye." This is strange because when I use a WebControl to get the HTML ( by calling .Navigate(url) and then .DocumentText), I receive the different HTML codes - which in turn is exactly what I see when open the website by Firefox & view the source code from Firefox. I read DownloadData() is downloading source that is completely wrong. Source view in Firefox different than that downloaded. - Stack Overflow and found the answer to my symptom. But I don't know how to set the User-Agent. Please help.

    Read the article

  • [NAnt] About "nant::get-base-directory()"

    - by Nam Gi VU
    As in http://nant.sourceforge.net/release/latest/help/functions/nant.get-base-directory.html, they explaint the meaning of this function is: The base directory of the appdomain in which NAnt is running. I don't know what does appdomain mean! Someone please explain it for me. Thank you.

    Read the article

  • ASP.NET MVC - Javascript array always passed to controller as null

    - by Xuan Vu
    I'm having some problem with passing a javascript array to the controller. I have several checkboxes on my View, when a checkbox is checked, its ID will be saved to an array and then I need to use that array in the controller. Here are the code: VIEW: var selectedSearchUsers = new Array(); $(document).ready(function () { $("#userSearch").click(function () { selectedSearchUsers.length = 0; ShowLoading(); $.ajax({ type: "POST", url: '/manage/searchusers', dataType: "json", data: $("#userSearchForm").serialize(), success: function (result) { UserSearchSuccess(result); }, cache: false, complete: function () { HideLoading(); } }); }); $(".userSearchOption").live("change", function () { var box = $(this); var id = box.attr("dataId"); var checked = box.attr("checked"); if (checked) { selectedSearchUsers.push(id); } else { selectedSearchUsers.splice(selectedSearchUsers.indexOf(id), 1); } }); $("#Send").click(function () { var postUserIDs = { values: selectedSearchUsers }; ShowLoading(); $.post("/Manage/ComposeMessage", postUserIDs, function (data) { }, "json"); }); }); When the "Send" button is clicked, I want to pass the selectedSearchUsers to the "ComposeMessage" action. Here is the Action code: public JsonResult ComposeMessage(List values) { //int count = selectedSearchUsers.Length; string count = values.Count.ToString(); return Json(count); } However, the List values is always null. Any idea why? Thank you very much.

    Read the article

  • How to use XmlPeek task?

    - by Nam Gi VU
    I've read in the MSDN MSBuild Task Reference about XmlPeek task at http://msdn.microsoft.com/en-us/library/ff598684(v=VS.100).aspx but I cannot use it in my MSBuild script. If you have used this before, please show me how!

    Read the article

  • My profile avatar doesn't work! [closed]

    - by Nam Gi VU
    How can I change my avatar on stackoverflow.com? I click the change picture link in my profile but it link to gravatar website, then I select the picture for my gravatar associated with my email. But my avatar on stackoverflow.com still not changes after 24hours as announced. Somebody has a work-around? Please help!

    Read the article

  • How do I add a click handler to a new element when I create it? [closed]

    - by vicky
    How do I add a click handler to a new element when I create it? This is what I have tried, but it does not work as expected: DeCheBX = $('MyDiv').insert(new Element('input', { 'type': 'checkbox', 'id': "Img" + obj[i].Nam, 'value': obj[i].IM, 'onClick': SayHi(this) })); document.body.appendChild(DeCheBX); DeImg = $('MyDiv').insert(new Element('img', { 'id': "Imgx" + obj[i].Nam, 'src': obj[i].IM })); document.body.appendChild(DeImg); } SayHi = function (x) { try { if ($(x).checked == true) { alert("press" + x); } } catch (e) { alert("error");

    Read the article

  • How to import a macro file (previously exported as .bas file) to Microsoft Word using command line?

    - by Nam Gi VU
    I'm writing a command-line program that has a step in which I need to replace text in a Word file. The replacing task is accomplished using Word macro. What I need to do now is to call this macro from command-line. At the moment we can do this by using the -mMacroName parameter of 'winword.exe', i.e. \winword.exe -mMacroName. But this need the macro to be already available as a global macro. Since I need to run the program on another computer, I need to import the above replacing macro programatically... and I don't know how to do this. Please help.

    Read the article

  • How to get import custom tasks more than once without warning message?

    - by Nam Gi VU
    I'm using some custom tasks from MSBuild Extension Pack (MEP). My projects are splitted among many files. In those files I import the MEP tasks using (twice or three times in two/three files). I receive the warning message when doing this like: ... warning MSB4011: "C:\Program Files\MSBuild\ExtensionPack\MSBuild.ExtensionPack.tasks" cannot be imported again. It was already imported at "D:...\Tasker.proj (5,3)". This is most likely a build authoring error. This subsequent import will be ignored. Does anyone know how to get rid of this warning message? Please help!

    Read the article

  • When does Visual Studio call target AfterBuild & BeforeBuild? And how is it handled when these targe

    - by Nam Gi VU
    Hi Fiburt, Today I meet a similar problem and it reminds me about this thread. In Visual Studio, if we open the .csproj file, we see that they tell us to uncomment the two targets AfterBuild and BeforeBuild so as to execute them after and before the build of the current project accordingly. My questions are: Where are these two targets called in Visual Studio? And how is it handled if the targets are not defined (be commented out) ?

    Read the article

  • How to use multifieldquery and filters in Lucene.net

    - by Khotu Nam
    I want to perform a multi field search on a lucene.net index but filter the results based on one of the fields. Here's what I'm currently doing: To index the fields the definitions are: doc.Add(new Field("id", id.ToString(), Field.Store.YES, Field.Index.UN_TOKENIZED)); doc.Add(new Field("title", title, Field.Store.NO, Field.Index.TOKENIZED)); doc.Add(new Field("summary", summary, Field.Store.NO, Field.Index.TOKENIZED, Field.TermVector.YES)); doc.Add(new Field("description", description, Field.Store.NO, Field.Index.TOKENIZED, Field.TermVector.YES)); doc.Add(new Field("distribution", distribution, Field.Store.NO, Field.Index.UN_TOKENIZED)); When I perform the search I do the following: MultiFieldQueryParser parser = new MultiFieldQueryParser(new string[]{"title", "summary", "description"}, analyzer); parser.SetDefaultOperator(QueryParser.Operator.AND); Query query = parser.Parse(text); BooleanQuery bq = new BooleanQuery(); TermQuery tq = new TermQuery(new Term("distribution", distribution)); bq.Add(tq, BooleanClause.Occur.MUST); Filter filter = new QueryFilter(bq); Hits hits = searcher.Search(query, filter); However, the result is always 0 hits. What am I doing wrong?

    Read the article

  • how to create run time element? where i am doin wrong help....help.....

    - by vicky
    new Ajax.Request('Handler.ashx', { method: 'get', onSuccess: function(transport) { var response = transport.responseText || "no response text"; //alert("Success! \n\n" + response); var obj = response.evalJSON(true); alert(obj[0].Nam); alert(obj[0].IM); for(i = 0; i < 4; i++) { $('MyDiv').insert( new Element('checkbox', { 'id': "Img" + obj[i].Nam, 'value': obj[i].IM }) ); return ($('MyDiv').innerHTML); } }, onFailure: function() { alert('Something went wrong...') } });

    Read the article

  • WebKitErrorDomain error 101

    - by Nam Young-jun
    The following code produces and error of: WebKitErrorDomain error 101 code: -(Void) searchBarSearchButtonClicked: (UISearchBar *) activeSearchBar { NSString * query = [searchBar.text stringByReplacingOccurrencesOfString: @ "" withString: @ "+"]; NSURL * url = [NSURL URLWithString: [NSString stringWithFormat: @ "http://http://www.google.com/search?q =%, query]]; NSURLRequest * requestObj = [NSURLRequest requestWithURL: url]; [Home loadRequest: requestObj]; } -(Void) loadView { [Super loadView]; CGRect bounds = [[UIScreen mainScreen] applicationFrame]; searchBar = [[UISearchBar alloc] initWithFrame: CGRectMake (0.0, 0.0, bounds.size.width, 48.0)]; searchBar.delegate = self; [Self.view addSubview: searchBar]; } I don't speak english and rely on a translator. Because of the language issue could this be a keyboard problem, or an encoding problem?

    Read the article

  • How to execute statements in order in objective c

    - by Vu Tu?n Anh
    When i tap on my button, my function was called [myBtn addTarget:self action:@selector(myFunction) forControlEvents:UIControlEventTouchUpInside]; In my function, a collection of complex statement will be executed and take a litte bit time to run, so i want to show Loading (UIActivityIndicatorView) as the following: -(void) addTradeAction { //Show Loading [SharedAppDelegate showLoading]; //disable user interaction self.view.userInteractionEnabled = NO; //execute call webservice in here - may be take 10s //Hide Loading [ShareAppDelegate hideLoading]; } When tap on myBtn (my Button) - after 3s or 4s, [ShareAppDelegate showLoading] was called. It is unusual when i use [ShareAppDelegate showLoading] on other Function, - it work very nice, i mean all the statement be executed in order. All i want, when i tap on My Button, Loading will be called immediatelly. Tks in advance

    Read the article

  • The submitHandler is not binded to the form after loading. why?

    - by Alex
    $(".normalform").click( function() { var hrf = $(this).attr("href"); var typ = $(this).attr("frm_type"); var cls = $(this).attr("class"); var nam = $(this).attr("frm_nam"); var url = $(this).attr("url"); //alert("href:"+hrf+", "+"type:"+typ+", "+"class:"+cls+", "+"name:"+nam+", "+"url:"+url+", "); $("#contentContainer").load(url, null, function() { //start validate : normalform jQuery("#normalform").validate({ submitHandler: function(form) { $('#submitbutton').attr('disabled', 'disabled'); jQuery("#normalform").ajaxSubmit({ target: "#result", error: function () { $('#submitbutton').removeAttr('disabled'); alert('Submission Error ! Try again.'); }, success: function (data) { $('#submitbutton').removeAttr('disabled'); }, clearForm: true }); } }); //end validate : normalform }); });

    Read the article

  • std::vector optimisation required

    - by marcp
    I've written a routine that uses std::vector<double> rather heavily. It runs rather slowly and AQTime seems to imply that I am constructing mountains of vectors but I'm not sure why I would be. For some context, my sample run iterates 10 times. Each iteration copies 3 c arrays of ~400 points into vectors and creates 3 new same sized vectors for output. Each output point might be the result of summing up to 20 points from 2 of the input vectors, which works out to a worst case of 10*400*3*2*20 = 480,000 dereferences. Incredibly the profiler indicates that some of the std:: methods are being called 46 MILLION times. I suspect I'm doing something wrong! Some code: vector<double>gdbChannel::GetVector() { if (fHaveDoubleData & (fLength > 0)) { double * pD = getDoublePointer(); vector<double>v(pD, pD + fLength); return v; } else { throw(Exception("attempt to retrieve vector on empty line")); ; } } void gdbChannel::SaveVector(GX_HANDLE _hLine, const vector<double> & V) { if (hLine != _hLine) { GetLine(_hLine, V.size(), true); } GX_DOUBLE * pData = getDoublePointer(); memcpy(pData, &V[0], V.size()*sizeof(V[0])); ReplaceData(); } ///This routine gets called 10 times bool SpecRatio::DoWork(GX_HANDLE_PTR pLine) { if (!(hKin.GetLine(*pLine, true) && hUin.GetLine(*pLine, true) && hTHin.GetLine(*pLine, true))) { return true; } vector<double>vK = hKin.GetVector(); vector<double>vU = hUin.GetVector(); vector<double>vTh = hTHin.GetVector(); if ((vK.size() == 0) || (vU.size() == 0) || (vTh.size() == 0)) { return true; } ///TODO: confirm all vectors the same lenghth len = vK.size(); vUK.clear(); // these 3 vectors are declared as private class members vUTh.clear(); vThK.clear(); vUK.reserve(len); vUTh.reserve(len); vThK.reserve(len); // TODO: ensure everything is same fidincr, fidstart and length for (int i = 0; i < len; i++) { if (vK.at(i) < MinK) { vUK.push_back(rDUMMY); vUTh.push_back(rDUMMY); vThK.push_back(rDUMMY); } else { vUK.push_back(RatioPoint(vU, vK, i, UMin, KMin)); vUTh.push_back(RatioPoint(vU, vTh, i, UMin, ThMin)); vThK.push_back(RatioPoint(vTh, vK, i, ThMin, KMin)); } } hUKout.setFidParams(hKin); hUKout.SaveVector(*pLine, vUK); hUTHout.setFidParams(hKin); hUTHout.SaveVector(*pLine, vUTh); hTHKout.setFidParams(hKin); hTHKout.SaveVector(*pLine, vThK); return TestError(); } double SpecRatio::VValue(vector<double>V, int Index) { double result; if ((Index < 0) || (Index >= len)) { result = 0; } else { try { result = V.at(Index); if (OasisUtils::isDummy(result)) { result = 0; } } catch (out_of_range) { result = 0; } } return result; } double SpecRatio::RatioPoint(vector<double>Num, vector<double>Denom, int Index, double NumMin, double DenomMin) { double num = VValue(Num, Index); double denom = VValue(Denom, Index); int s = 0; // Search equalled 10 in this case while (((num < NumMin) || (denom < DenomMin)) && (s < Search)) { num += VValue(Num, Index - s) + VValue(Num, Index + s); denom += VValue(Denom, Index - s) + VValue(Denom, Index + s); s++; } if ((num < NumMin) || (denom < DenomMin)) { return rDUMMY; } else { return num / denom; } } The top AQTime offenders are: std::_Uninit_copy , double *, std::allocator 3.65 secs and 115731 Hits std::_Construct 1.69 secs and 46450637 Hits std::_Vector_const_iterator ::operator !=1.66 secs and 46566395 Hits and so on... std::allocator<double>::construct, operator new, std::_Vector_const_iterator<double, std::allocator<double> >::operator ++, std::_Vector_const_iterator<double, std::allocator<double> >::operator * std::_Vector_const_iterator<double, std::allocator<double> >::operator == each get called over 46 million times. I'm obviously doing something wrong to cause all these objects to be created. Can anyone see my error(s)?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >