Repository: piskvorky/gensim

Issue:
Measure performance of gensim 4.0.0 vs previous versions
Not every 1-line decision; just ones that are in inner loops of hot-spot code.

Definitely a big TODO: compare performance before/after.

_Originally posted by @piskvorky in https://github.com/_render_node/MDExOlB1bGxSZXF1ZXN0MzQ5Mjk1NTk1/timeline/more_items_


Discussion:
This link is also broken for me – I get 400. @mpenkov this way of creating tickets seems more trouble than worth, with the context missing.
I'll take it up with github support. It's convenient, but only when it works.
@piskvorky From github support:

> This might be an uncaught edge case on our end. I have raised this up with our engineering team to investigate further.

I'll keep my eyes open for the problem in case it recurs.
Some Word2vec measurements here: https://github.com/RaRe-Technologies/gensim/pull/2939#issuecomment-691729995

I wonder what the original "Not every 1-line decision; just ones that are in inner loops of hot-spot code." was referring to though, the link is still broken. Probably some change of code deep in C loops.

Resolving patch:
diff --git a/gensim/models/word2vec.py b/gensim/models/word2vec.py
--- a/gensim/models/word2vec.py
+++ b/gensim/models/word2vec.py
@@ -1638,7 +1638,7 @@ def _log_train_end(self, raw_word_count, trained_word_count, total_elapsed, job_
 
         """
         logger.info(
-            "training on a %i raw words (%i effective words) took %.1fs, %.0f effective words/s",
+            "training on %i raw words (%i effective words) took %.1fs, %.0f effective words/s",
             raw_word_count, trained_word_count, total_elapsed, trained_word_count / total_elapsed
         )
 
diff --git a/gensim/scripts/benchmark.py b/gensim/scripts/benchmark.py
new file mode 100644
--- /dev/null
+++ b/gensim/scripts/benchmark.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2020 Radim Rehurek <me@radimrehurek.com>
+
+"""
+Help script (template) for benchmarking. Run with:
+
+  /usr/bin/time --format "%E elapsed\n%Mk max mem" python -m gensim.scripts.benchmark ~/gensim-data/text9/text9.txt
+
+"""
+
+import logging
+import sys
+
+from gensim.models.word2vec import Text8Corpus, LineSentence  # noqa: F401
+from gensim.models import FastText, Word2Vec, Doc2Vec, Phrases  # noqa: F401
+from gensim import __version__
+
+logger = logging.getLogger(__name__)
+
+
+if __name__ == "__main__":
+    logging.basicConfig(
+        format='%(asctime)s [%(processName)s/%(process)d] [%(levelname)s] %(name)s:%(lineno)d: %(message)s',
+        level=logging.INFO,
+    )
+
+    if len(sys.argv) < 2:
+        print(globals()['__doc__'] % locals())
+        sys.exit(1)
+
+    corpus = Text8Corpus(sys.argv[1])  # text8/text9 format from http://mattmahoney.net/dc/textdata.html
+    cls = FastText
+    cls(corpus, workers=12, epochs=1).save(f'/tmp/{cls.__name__}.gensim{__version__}')
diff --git a/gensim/utils.py b/gensim/utils.py
--- a/gensim/utils.py
+++ b/gensim/utils.py
@@ -535,7 +535,7 @@ def _smart_save(self, fname, separately=None, sep_limit=10 * 1024**2, ignore=fro
         in separate files. The automatic check is not performed in this case.
 
         """
-        logger.info("saving %s object under %s, separately %s", self.__class__.__name__, fname, separately)
+        logger.info("saving %s under %s, separately %s", self, fname, separately)
 
         compress, subname = SaveLoad._adapt_by_suffix(fname)
 


Test patch: