C++ (Qt) wordCount.remove(5,100); wordCount.remove(QRegExp("^[0]")); wordCount.remove(QRegExp("^[0]")); wordCount.remove(QRegExp("^[0]")); wordCount.remove(QRegExp("^[0]"));
C++ (Qt)void MainWindow::bufferButtonSave(){ QTime tm; tm.start(); QClipboard *clipboard = QApplication::clipboard(); QString originalText = clipboard->text(); QString countItemFullString; QString countItemString, countItemStringZero; QStringList itemList; int countItem(0); int countItemFull(0); qDebug() << "Reade Data: " << tm.elapsed(); tm.start(); originalText = originalText.toLower(); qDebug() << "Data toLower: " << tm.elapsed(); textory.clear(); tm.start(); itemList = originalText.split(QRegExp("[^a-z]"),QString::SkipEmptyParts); QHash<QString, int> frequencyMap; foreach (QString Item, itemList) ++frequencyMap[Item]; qDebug() << "Data split [^a-z]: " << tm.elapsed(); tm.start(); QList<QString> frequencyList; QHashIterator<QString,int> Iter(frequencyMap); while(Iter.hasNext()) { Iter.next(); countItem = Iter.value(); countItemString.setNum(countItem); countItemStringZero = countItemString; // ОРГАНИЗОВЫВАЕМ СОРТИРОВКУ if(countItem <10 )countItemStringZero = "00000" + countItemStringZero; if(countItem >9 && countItem <100 )countItemStringZero = "0000" + countItemStringZero; if(countItem >99 && countItem <1000 )countItemStringZero = "000" + countItemStringZero; if(countItem >999 && countItem <10000 )countItemStringZero = "00" + countItemStringZero; if(countItem >9999 && countItem <100000 )countItemStringZero = "0" + countItemStringZero; countItemFull = countItemFull + countItem; frequencyList.append(countItemStringZero + "_" + Iter.key() + "\t" + countItemString ); } qDebug() << "Add zero: " << tm.elapsed(); tm.start(); qSort(frequencyList); textory.enableAdd( true ); QString wordItem, wordCount; qDebug() << "Data sort: " << tm.elapsed(); tm.start(); foreach (QString itm, frequencyList) { itm.remove(0,7); textory.addItem( Textory::Item( 1, itm ) ); } qDebug() << "Clear zero: " << tm.elapsed(); tm.start(); countItemFullString.setNum(countItemFull); ui.textoryPaneWidget->getTextoryLabel().setText( "Frequency list (" + countItemFullString + ")" ); qDebug() << "Write name: " << tm.elapsed();}
C++ (Qt) textory.addItem( Textory::Item( 1, itm ) );
BashOld: 15629 15211 Majestio: 17590 15211 m_ax: [b]9028[/b] 15211
Perl#!/usr/bin/perl use Time::HiRes qw(gettimeofday); open(FD,"test.txt") || die "Shit happiness!";$T = join("",<FD>);close(FD); $Start = gettimeofday(); for($I=0; $I<100; $I++) { map { $F{$_}++ } split(/[\s\.,:;\-()]+/,$T);} $Elapsed = gettimeofday() - $Start; print "<br>Elapsed: $Elapsed";